Click to See Complete Forum and Search --> : make form fields available depending on user input
chapm4
11-30-2005, 04:49 PM
Don't know what all is available to do this in (javascript, etc) so I am putting the question here.
I have a form, when a user selcts a radio button such as credit card, check, or PO, certain fields should be available according to which one they select. How do I do this and in what platform?
kiwibrit
11-30-2005, 07:14 PM
You can do this either with javascript (but using that would create an accessibility problem - and many browsers will have it turned of, anyway) or you can use a server side language such as php, and have a series of pages that display in accordance with the preceding on - you often see that in online shopping. It does mean loading of separate pages, but they should load quite quickly.
soccermatrix
12-08-2005, 01:50 PM
What you need to do is place all fields, depending on what the user selects, within <div>. In other words, use CSS.
Here is a quick example of what you can do:
<form id="form1" name="form1" method="post" action="">
<label>Credit Card</label>
<input name="radiobutton" type="radio" value="radiobutton" onclick="credit.style.display=''; check.style.display='none'" /><br />
<label>Check</label>
<input name="radiobutton" type="radio" value="radiobutton" onclick="credit.style.display='none'; check.style.display=''"/><br />
<div id="credit" style="display:none">
<label>Card Number</label>
<input name="creditNumber" type="text" />
</div>
<div id="check" style="display:none">
<label>Check Routing</label>
<input name="checkRouting" type="text" />
</div>
</form>