Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing variables into jscript functions

Status
Not open for further replies.

crispo

Programmer
Joined
Jan 25, 2002
Messages
2
Location
US
how can i pass my cf variable in jscript... for example instead of location='index.htm' make it function as location='#variable_name#'

thx
 
remember javascript is client side so to pass the value of variables you would just use #variablename#

e.g.

<script language=&quot;javascript&quot; >

alert('#variablename#')

<script>

remember the value is only inserted once when the page is generated.

HTH
 
thanks... much appreciated... i am still having problems... i'll try to explain it... i am using jscript for a multi-category menu... in my jscript i am pulling the attributes where i am specifying links which are generated from a query.... whenever i use #variablename# in my javascript in simply reloads the page...

>>>
addMenuItem(&quot;Add/Verify Information&quot;, &quot;location='#variablename#'&quot;);
<<<

any other ideas... thanks a bunch...

i think i need to switch it to a jscript <b>var</b> instead... but not quite sure where to start...
 
I assume that addMenuItem is a function that you created. The first argument is what the user sees on the menu and the second argument is the JavaScript code that you want to execute when the user slectes the menu item. Is that correct?

Are you saying that whenever you write:

addMenuItem(&quot;Add/Verify Information&quot;, &quot;location='#variablename#'&quot;);

in your JavaScript, that the page is re-loaded at the moment that the above line executes? If so, try to find out why. JS is apparently executing it instead of interpreting it as a string.

If that's not what you're saying, please clarify. Exactly when does &quot;it simply reload the page&quot;?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top