开发者

Display content based on Select Menu dropdown change

开发者 https://www.devze.com 2023-04-12 11:14 出处:网络
I\'m currently using the following to display an input field when I change a dropdown menu selection:

I'm currently using the following to display an input field when I change a dropdown menu selection:

<select id="delivery_country" name="d_country" onchange="
 if (this.selectedIndex==14){
  this.form['statesUSA'].style.visibility='visible'
 }else {
  this.form['statesUSA'].style.visibility='hidden'
 };">

Howe开发者_C百科ver, this only changes the input form element called "statesUSA".

If I want to show the div that this form element is inside, how do I do this?

For the record, my HTML reads:

<div id="usa"> <input type="text" id="statesUSA" /> </div>

Many thanks for any pointers.


use document.getElementById(id)

this:

<select id="delivery_country" name="d_country" onchange="if (this.selectedIndex==14){document.getElementById('usa').style.visibility='visible'}else {document.getElementById('usa').style.visibility='hidden'};">
0

精彩评论

暂无评论...
验证码 换一张
取 消