I'm a beginner in using javascript and i need a reply so urgent;
i have a problem in using javascript with asp the problem is that i
want to define a global variable and then change the value of it after
clicking on a link which activate a function that changes the global
variable. this variable i use as the value of a hidden field in a form.
my problem is that the global variable dosen't change.
this is the code i used to do this:
//the function which shows a layer and changes the variable
<script>
var month_na=0;//global variable
function show_layer(month_no)
{
month_na=month_no;
document.getElementById("layern").style.visibility ="visible";
return month_na;
}
</script>
//the link code <%=rs_trans_mo(0)%> is asp code and is evaluated to 3
<a onclick="show_layer(<%=rs_trans_mo(0)%>);" style="color:
#0000FF;cursor:hand;">+</a>
//the form that uses the global variable
<td id="layern" style="visibility:hidden;" nowrap>
<form method="POST" action="insert_trans.asp">
day: <input type="text" name="day_no" size="20">
<p>main rate:<input type="text" name="main_rate" size="20"></p>
<p>paid rate:<input type="text" name="paid_rate" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
<script language=javascript>
//the hidden field used to send the global variable to the
insert_trans.asp page
if (month_na!=0)
{document.write ('<input type="hidden" name="month_no"
value="'+month_na+'">');}
</script>
<input type="hidden" name="year_no" value="<%=year_no%>">
</form>
</td>
logically this code must work but i don't know why it dosen't. plz try
to reply ass soon as possible coz i need this very urgently.
thank u all