In this code, if I click the order details, that form should display, and if I click the shipping details address that form should display and the order form should hide.
However here both the forms are displaying in my code.
<!DOCTYPE html>
<html>
<head>
<script>
function orderdetails() {
document.getElementById('orderdetails').style.display = "block";
}
function shippingdetails() {
document.getElementById('shippingdetails').style.display = "block";
}
function ordersummary() {
document.getElementById('welcomeDiv1').style.display = "block";
}
function payment() {
document.getElementById('welcomeDiv1').style.display = "block";
}
</script>
</head>
<body>
<a href="javascript:void(0);" value="Show Div" onclick="orderdetails()" >Order Details</a>
<a href="javascript:void(0);" value="Show Div1" onclick="shippingdetails()">Shipping Details</a>
<a href="javascript:void(0);" value="Show Div12" onclick="ordersummary()">Order Summary</a>
<a href="javascript:void(0);" value="Show Div12" onclick="payment()">Payment</a>
<div id="orderdetails" style="display:none;" class="answer_list" >
<table width="200" border="0">
<h3><u><b>Order Details</b></u></h3>
<tr>
<th scope="row"><label>Name*</label></th>
<td><input name="name" type="text"></td>
</tr>
<tr>
<th scope="row"><label>Email*</label>;</th>
<td><input name="mail" type="text"></td>
</tr>
<tr>
<th scope="row"><label>Mobile Number*</label></th>
<td><input name="mobile" type="text"></td>
</tr>
<tr>
<th scope="row"><label>Land Line</label></th>
<td><input name="phone" type="text"></td>
</tr>
</table>
</div>
<div id="shippingdetails" style="display:none;" class="answer_list" >
<br/>
<table width="200" border="0">
<h3><u><b>Shipping Details</b></u></h3>
<br/>
<tr>
<th scope="row"><label>Full Name*</label></th>
<td><input name="name" type="text"></td>
</tr>
<tr>
<th scope="row"><label>Address*</label></th>
<td><textarea name="address" cols="" rows=""></textarea></td>
</tr>
<tr>
<th scope="row"><label>Nearest Land Mark*</label>;</th>
<td><input name="mail" type="text"></td>
</tr>
<tr>
<th scope="row"><label>City</label></th>
<td><input name="city" type="text"></td>
</tr>
<tr>
<th scope="row"><label>State</label></th>
<td><form name="form" id="form">
<select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
<option>Tamil Nadu</option>
<option>Kerala</option>
<option>Orissa</option>
<option>Delhi</option>
<option>Andhrs</option>
<option>Karntaka</option>
</select>
</form></td>
</tr>
<tr>
<th scope="row"><label>Pin Code*</label></th>
<td><input name="code" type="text"></td>
</tr><tr>
<th scope="row"><label>Mobile Number*</label></th>
<td><input name="city" type="text"></td>
</tr><tr>
<th scope="row"><label>Land Line</label></th>
<td><input name="city" type="text"></td>
</tr>
</table>
</div>
</body>
</html>
Don’t just display the form, hide the others as well.
To prevent users from going back to the previous form, you can check if they have completed that particular form.
In your form, give the required items a class name:
And give the “Order Details” link an ID:
Then put down the following before
</body>to look for all the required fields in “Ordering Details”:Finally use the following functions to check if the user should be allowed to go back to the ordering details form.
See fiddle.