View Full Version : Need help on sending javascript variable to ASP

04-10-2007, 04:49 PM
ok this code, I got a href link that works with a counter for the value in a javascript variable, i put that value in a hidden field, then assign that value to a javascript variable.

But it's not working, can anyone help me?


<input type="hidden" name="custom" value="" />

var global=0;
function dynamic()
var tmp=1;

<% if len(Loccustom)=0 then
<td height="15" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">

<td width="244" height="15" align="center" valign="middle"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td width="168" align="center" valign="middle"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td width="163" align="center" valign="middle"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr> <%end if%>
<td height="15" colspan="3" valign="middle">&nbsp;&nbsp;<a href="javascript:dynamic();">Click here to add charges not in selection</a></td>

04-10-2007, 07:21 PM
You aren't getting the value because you haven't submitted the form yet (at least not in the snippet you provided).

And because ASP is server-side and JS is client-side, something has to happen to reload the page first.

Have you tried modifying your dynamic() function to include a document.frm.submit()? That would force the Request.Form() to take on the value that JS has submitted.

04-18-2007, 03:32 PM
If you want javascript to communicate with ASP dynamically then you can use Ajax to call the ASP script, passing the variable in a querystring.