PDA

View Full Version : Forms



norbert_ds
13 Jul 2009, 10:23 PM
Hi all,

Can any of you'll guide me to some tutorials that explains how one can create a dropdown list and based on the choice, add additional input fields?

Thanks very much in anticipation.

Norbert

hpwebsolutions
14 Jul 2009, 01:00 AM
Hi norbert,
Your basic javascript tutorial will teach you how to do the following.

Use the onchange attribute in the <select> opening tag to call a javascript method that adds the input fields. This allows you to add fields without refreshing the page, which is both quick and snazzy client-side. Your javascript method can either 1) set the hidden field's css display value from the preset 'hidden' to 'block' or other such display value or 2) just add more input fields to the page, which will require a little bit more coding. You could put the area you want the new input field to be displayed in into an empty div and use the javascript .innerHTML property to define the empty div's content.

You can use PHP or some other server side programming to do this, but overall, it is probably easier to use javascript, though in the future you might want to make the form work for those with javascript turned off if you are expecting a lot of people to use the form. I'm sorry but I don't know of any tutorials specific to your question, but you can learn about onchange at http://www.w3schools.com/jsref/jsref_onchange.asp.