Проблем с HTML форма

R0adRunner

Registered
Здравейте.
Чудя се как да постигна следното нещо. Значи идеята е следната:
има две полета които са тип радио да приемем че едното се казва автомобил а другото лодка. Идеята ми е след като избера да кажем лодка отдолу да се появят едни полета за попълване а когато избера автомобил да са други.
Някакви идеи?
 
Ето го отговора


<html>
<head>
<title>Modifying Forms with DHTML</title>
<script language="javascript">
function Display(which) {
ma=document.getElementById("mail");
em=document.getElementById("email");
ph=document.getElementById("phone");
if (which=="mail") ma.style.display="block";
else ma.style.display="none";
if (which=="email") em.style.display="block";
else em.style.display="none";
if (which=="phone") ph.style.display="block";
else ph.style.display="none";
}
</script>
</head>
<body>
<h1>Modifying Forms with DHTML</h1>
<p>The form below changes depending on the radio button
selected.</p>
<hr>
<form name="form1">
<p>How would you like us to contact you?</p>
<input type="radio" name="type" value="mail" checked
onClick="Display('mail');">

By mail
<input type="radio" name="type" value="email"
onClick="Display('email');">
By email
<input type="radio" name="type" value="phone"
onClick="Display('phone');">
By phone
<br>
<div ID="mail" style="display:block;">
<b>Address 1:</b> <input type="text" name="address1" size="25">
<br>
<b>Address 2:</b> <input type="text" name="address2" size="25">

<br>
<b>City:</b> <input type="text" name="city" size="14">
<b>State:</b> <input type="text" name="state" size="5">
<b>Zip:</b> <input type="text" name="zip" size="9">
</div>
<div ID="email" style="display:none">
<b>Email address:</b>
<input type="text" name="email" size="25">
</div>
<div ID="phone" style="display:none">

<b>Phone:</b>
<input type="text" name="phone" size="15">
</div>
</form>
</body>
</html>
 

Back
Горе