Click to See Complete Forum and Search --> : Dynmic forms
mandavae
08-21-2003, 08:41 PM
Folks
Can someone help on ASAP.
I had two radio buttons "Yes" and "NO". When I clcik on Yes I need additinol form fields to be displayed and click "No" form fileds must disappear.
Example:
Are you veteran: yes and No
if I click on Yes, I should see additional form fileds and when I click no, they should disappear.
Your help is greatly appreciated
If some has sample of code, I can use it.
AdamBrill
08-21-2003, 10:54 PM
Here is a simple example that should help you:<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function show(){
document.getElementById('extra').style.display="inline";
}
function hide(){
document.getElementById('extra').style.display="none";
}
</script>
</head>
<body>
<form action="wherever.php" method="POST">
Show: <input type=radio name="extras" onclick="show()">
Hide: <input type=radio name="extras" onclick="hide()"><br>
<div id="extra">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<input type="text" name="text3"><br>
</div>
<input type="submit" value="Submit!">
</form>
</body>
</html>
mandavae
08-22-2003, 09:25 AM
Thanks you for your sample, but I did want to see the test boxes to be displayed until they click on show.
Can you help me on this.
Your help greatly appreciated
AdamBrill
08-22-2003, 09:52 AM
Try this instead:<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
code="";
function show(){
document.getElementById('extra').innerHTML=code;
}
function hide(){
if(document.getElementById('extra').innerHTML!= ""){
code=document.getElementById('extra').innerHTML;
document.getElementById('extra').innerHTML="";
}
}
</script>
</head>
<body onload="hide()">
<form action="wherever.php" method="POST">
Show: <input type=radio name="extras" onclick="show()">
Hide: <input type=radio name="extras" onclick="hide()"><br>
<div id="extra">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<input type="text" name="text3"><br>
</div>
<input type="submit" value="Submit!">
</form>
</body>
</html>