
June 30th, 2008, 03:17 PM
|
|
Contributing User
|
|
Join Date: Apr 2006
Posts: 1,136
 
Time spent in forums: 1 Week 6 Days 14 h 27 m 24 sec
Reputation Power: 4
|
|
|
Show hide div problem
Hi,
I have a drop down which has 3 values when one of them is selected I want to show content related to that value
in a div
when the page is first loaded I dont want to show any of the div's
Can someone tell me what i am doing wrong when the page is loaded first it displays the credit card div
and when i choose the options it doesnt give any error messages but it doesnt change the div's
Code:
Default
here is the code
Code:
<%
Option Explicit
Dim ReserveDisplaycredit, ReserveDisplaycash, ReserveDisplaycheck
ReserveDisplaycredit = "none"
ReserveDisplaycash = "none"
ReserveDisplaycheck = "none"
Response.write "ReserveDisplaycredit:-" & ReserveDisplaycredit & "<br/>"
Response.write "ReserveDisplaycash" & ReserveDisplaycash & "<br/>"
Response.write "ReserveDisplaycheck" & ReserveDisplaycheck & "<br/>"
%>
<head>
<title>Main</title>
<script type="text/javascript">
<!--
function getStyleObject(objectId)
{
if (document.getElementById && document.getElementById(objectId))
{
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId))
{
return document.all(objectId).style;
}
else
{
return false;
}
}
function calloptionpay()
{
var sel_payway = document.getElementById("payway")
var getpayway = sel_payway.options[sel_payway.selectedIndex].text
alert(getpayway);
if(getpayway=="Cash")
{
alert("are we here");
hidecredit();
hidecheck();
changeDivcash('reservecash', 'block');
}
else if (getpayway=="Check")
{
hidecredit();
hidecash();
changeDivcheck('reservecheck', 'block');
}
else if (getpayway=="Credit Card")
{
hidecheck();
hidecash();
changeDivcredit('reservecredit', 'block');
}
}
function changeDivcash(the_div,the_change)
{
var the_style = getStyleObject(the_div);
if (the_style != false)
{
the_style.display = the_change;
}
}
function changeDivcredit(the_div,the_change)
{
alert("change credit");
var the_style = getStyleObject(the_div);
if (the_style != false)
{
the_style.display = the_change;
}
}
function changeDivcheck(the_div,the_change)
{
alert("change check");
var the_style = getStyleObject(the_div);
if (the_style != false)
{
the_style.display = the_change;
}
}
function hidecheck()
{
alert("hide check");
changeDivcheck("reservecheck", "none");
}
function hidecash()
{
changeDivcash("reservecash", "none");
}
function hidecredit()
{
alert("hide credit");
changeDivcredit("reservecredit", "none");
}
//form Validation ends
// -->
</script>
</head>
<body>
<form name="frm1" id="frm1" method="post" action="confirm.asp">
<table>
<td>Payment Method:</td>
<td><select name="payway" id="payway" onChange="calloptionpay();">
<option value="">Select the Payment Type</option>
<option value="Cash">Cash</option>
<option value="Check">Check</option>
<option value="Credit Card">Credit Card</option>
</select>
</td>
</tr>
<div id="reservecash" style="display: <%=ReserveDisplaycash%>;">
Cash
</div>
<div id="reservecheck" style="display: <%=ReserveDisplaycheck%>;">
check
</div>
<div id="reservecredit" style="display: <%=ReserveDisplaycredit%>;">
credit
</div>
<%
Response.write "ReserveDisplaycredit:-" & ReserveDisplaycredit & "<br/>"
Response.write "ReserveDisplaycash" & ReserveDisplaycash & "<br/>"
Response.write "ReserveDisplaycheck" & ReserveDisplaycheck & "<br/>"
%>
</body>
</html>
|