p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   passing params on an href function call (http://p2p.wrox.com/showthread.php?t=35539)

geogomez November 28th, 2005 10:10 PM

passing params on an href function call
 
Hi you all:

I am trying to invoke a function and pass a string parameter using an <a href=... element, but keep getting an error. Passing a number works ok. The parameter data would come from the hidden input field.
Is it a matter of syntax or it cannot be done?

Here is the code:

#65279;<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META NAME="GENERATOR" Content="Microsoft Visual Studio">
<TITLE>Test</TITLE>
<script language="JavaScript">
function anyFunc(vparam)
{
    var oTR=window.document.all.DDTable.insertRow();
    var oTD=oTR.insertCell();
    oTD.innerText=vparam;
}
</script>
</head>
<BODY>
<input type="hidden" name="hdnName" value="ABC">
<table cellspacing=1 cellpadding=1 width=300 border=1 id="DDTable" >
  <tr>
    <td><a href='javascript:anyFunc()'>Test data</a></td>
  </tr>
</table></BODY></HTML>



ChrisScott November 29th, 2005 06:26 AM

You don't appear to be passing any parameter in your code. When you pass a string, is it in quotes?

Cheers,

Chris



All times are GMT -4. The time now is 11:28 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.