Display two Textboxes on change of drop down list

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Madhum
Forum Newbie
Posts: 7
Joined: Fri Feb 01, 2008 3:40 am

Display two Textboxes on change of drop down list

Post by Madhum »

Hi to all,

i have a data entry form with a drop down list.in drop down its having personal & office options to select.when user select personal,next to drop down it should be display a textbox.then user fill his personel telephone number.then user select the Office from the same drop down and again it is displaying another textbox in same place of first textbox.
i have a code to do this.but it's displaying text boxes in two places.this is the code.

<select onchange="if (this.selectedIndex==2){this.form['box'].style.visibility='visible'}else {this.form['box'].style.visibility='hidden'} if (this.selectedIndex==3){this.form['box1'].style.visibility='visible'}else {this.form['box1'].style.visibility='hidden'};">
<option value="">0</option>
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
<input style="visibility:hidden;" type="text" name="box"><input style="visibility:hidden;" type="text" name="box1">


can someone help me to do this.it's urgent.i'm stuck on this.
eskio
Forum Commoner
Posts: 66
Joined: Tue Apr 01, 2008 1:00 am

Re: Display two Textboxes on change of drop down list

Post by eskio »

hi,

why don't u use one text box <input style="visibility:hidden;" type="text" name="box"> instead of 2. And when u save the data, u can save to personal or to office according to the list box (select) value.
Post Reply