Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide / Reveal Form elements?

Status
Not open for further replies.

rhyno2k

IS-IT--Management
Jun 9, 2001
222
US
Hi,


Is there a way to have initially hidden form elements appear on a condition - such as when a certain option is selected?

e.g.

"Which car do you prefer: [Corvette | Camaro]"

ONLY upon selecting Camaro do the next form fields appear like "Which color? What type of engine? etc.".


Thanks,
--RHYNO

 
I think your looking for client side code:

<form name=&quot;frm&quot;>
<input type=&quot;radio&quot; onclick=&quot;document.frm.text1.style.visibility='visible';&quot;>option1
<input type=&quot;radio&quot; onclick=&quot;document.frm.text2.style.visibility='visible';&quot;>option2
<input name=&quot;text1&quot; type=&quot;text&quot; style=&quot;visibility:hidden;&quot;>
<input type=&quot;text2&quot; type=&quot;text&quot; style=&quot;visibility:hidden;&quot;>
</from>
 
Spans are pretty cool for client side.

<span id=&quot;myspan&quot;>Initial Value</span>

<input type=&quot;button&quot; value=&quot;Change Value&quot; onclick=&quot;changeval()&quot;>

<script>
function changeval()
{
document.myspan.innerHTML = &quot;<input type='text' value='Now I'm a textbox!'>&quot;
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top