Jump to content


Photo

Showing/Hiding fields Help


  • Please log in to reply
3 replies to this topic

#1 allydm

allydm
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 10 October 2006 - 10:42 PM

Hi there. I have a form with a drop down selection box, and if someone selects the option in it called 'Other' then i would like a text entry box to appear.

So far i have...

<select name="subject" id="subject">
     <option value="Purchasing Artwork">Purchasing Artwork</option>
     <option value="Viewing Artwork">Viewing Artwork</option>
     <option value="Commissions">Commissions</option>
     <option value="Other" onSelect="document.getElementById('iAmHidden').style='visibility:visible;';" />Other</option>
</select>

<div style="visibility:hidden; display:none;" id="iAmHidden">
	<input name="reason" type="text" id="reason" value="Please Specify">
</div>

However this isn't achieving the effect i'm after (the box won't display!). Can anyone see why? Or suggest a better code.

Thanks for any help guys/gals.

Alex.

#2 FrOzeN

FrOzeN
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 11 October 2006 - 08:15 AM

Try:
<select name="subject" id="subject">
     <option value="Purchasing Artwork">Purchasing Artwork</option>
     <option value="Viewing Artwork">Viewing Artwork</option>
     <option value="Commissions">Commissions</option>
     <option value="Other" onSelect="document.getElementById('iAmHidden').style.visibility = 'visible';" />Other</option>
</select>

<div style="visibility: hidden;" id="iAmHidden">
	<input name="reason" type="text" id="reason" value="Please Specify">
</div>


#3 allydm

allydm
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 11 October 2006 - 12:38 PM

Hi.

Unfortunatly it is still not showing even when the 'Other' option is selected.

Any ideas?

Thanks.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 11 October 2006 - 10:58 PM

You can't use onselect for an OPTION tag... use onchange on the SELECT tag instead.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users