document.getElementByID using HTML Radio Buttons
Posted: Sun Sep 05, 2010 3:17 pm
I am using document.getElementByID with HTML Radio Buttons, but it is not working. Any help would be appreciated.
Thanks. Scripts below:
<script type="text/javascript">
function hideAll() {
document.getElementById("existing").style.display="none";
document.getElementById("delivery").style.display="none";
}
function doIt() {
if (document.getElementById('q').value=="new") {
document.getElementById("existing").style.display="none";
document.getElementById("delivery").style.display="none";
window.location="cust-query2.php?cust_id=0";
}
if (document.getElementById('q').value=="existing") { alert("hello");
document.getElementById("existing").style.display="";
document.getElementById("delivery").style.display="none";
}
if (document.getElementById('q').value=="delivery") {
document.getElementById("existing").style.display="none";
document.getElementById("delivery").style.display="";
}
}
</script>
<body onLoad="hideAll()">
<div align="center">
<table width="70%" border="0">
<tr valign="top">
<th scope="row"><h2 align="left">Please Select an Option:</h2>
<form name="myform" onSubmit="doIt()" action="">
<p align="left" class="indent">
<input type="radio" name="fm" id="q" value="new">
<label>New Customer</label>
<br />
<input type="radio" name="fm" id="q" value="existing">
<label>Existing Customer</label>
<br />
<!--<input type="radio" id="q" value="s">
<label>Customer Search</label>
<br />-->
<input type="radio" name="fm" id="q" value="delivery">
<label>Print Delivery Information</label>
<br /><br />
<input type="submit" value="Submit" />
</form>
</p>
<div id="existing" align="left" class="indent">
<form action="cust-query2.php" method="post">
Enter Phone Number:
<input type="text" name="cust_id" />
<input name="submit" type="submit" />
</p>
</form>
</div>
<div id="delivery" align="left" class="indent">
<form method="post" action="search_delivery_by_date1.php">
Enter Date: <input type="text" name="date" />
Enter Time:
<select name="ampm">
<option>AM</option>
<option>PM</option>
</select>
Enter City:
<select name="city">
<option>Boro Park</option>
<option>Flatbush</option>
<option>Williamsburg</option>
</select>
<input type="submit" value="Print Delivery Information">
</form>
</div>
Thanks. Scripts below:
<script type="text/javascript">
function hideAll() {
document.getElementById("existing").style.display="none";
document.getElementById("delivery").style.display="none";
}
function doIt() {
if (document.getElementById('q').value=="new") {
document.getElementById("existing").style.display="none";
document.getElementById("delivery").style.display="none";
window.location="cust-query2.php?cust_id=0";
}
if (document.getElementById('q').value=="existing") { alert("hello");
document.getElementById("existing").style.display="";
document.getElementById("delivery").style.display="none";
}
if (document.getElementById('q').value=="delivery") {
document.getElementById("existing").style.display="none";
document.getElementById("delivery").style.display="";
}
}
</script>
<body onLoad="hideAll()">
<div align="center">
<table width="70%" border="0">
<tr valign="top">
<th scope="row"><h2 align="left">Please Select an Option:</h2>
<form name="myform" onSubmit="doIt()" action="">
<p align="left" class="indent">
<input type="radio" name="fm" id="q" value="new">
<label>New Customer</label>
<br />
<input type="radio" name="fm" id="q" value="existing">
<label>Existing Customer</label>
<br />
<!--<input type="radio" id="q" value="s">
<label>Customer Search</label>
<br />-->
<input type="radio" name="fm" id="q" value="delivery">
<label>Print Delivery Information</label>
<br /><br />
<input type="submit" value="Submit" />
</form>
</p>
<div id="existing" align="left" class="indent">
<form action="cust-query2.php" method="post">
Enter Phone Number:
<input type="text" name="cust_id" />
<input name="submit" type="submit" />
</p>
</form>
</div>
<div id="delivery" align="left" class="indent">
<form method="post" action="search_delivery_by_date1.php">
Enter Date: <input type="text" name="date" />
Enter Time:
<select name="ampm">
<option>AM</option>
<option>PM</option>
</select>
Enter City:
<select name="city">
<option>Boro Park</option>
<option>Flatbush</option>
<option>Williamsburg</option>
</select>
<input type="submit" value="Print Delivery Information">
</form>
</div>