View Full Version : passing variable to javascript and using as command

10-22-2003, 08:45 AM
I'm trying to pass a variable created in ASP to a javascript function so that i can use it as a command, if i output the string i pass, it looks fine, but javascript just treats it as text :(

any suggestions Gratefully recieved


The Generated Code that passes the variable:

<select name='PPEventQTYG' onchange='UpdatePPEventTotal("orderForm.PPEventQTYG.value")' >
<option value ='0'>0</option>
<option value ='1'>1</option>
<option value ='2'>2</option>

The Javascript Function

function UpdatePPEventTotal(Qty){
orderForm.PPEventTotal.value = Qty;

10-22-2003, 09:49 AM
It's treated as text because you had quotes in it.
You should remove it.

<select name="PPEventQTYG" onchange="UpdatePPEventTotal(this.form.PPEventQTYG.value)" >

you can also use:


but using this.form is better since you don't have to know what the form name is.

10-22-2003, 10:00 AM
Thanks Glenn

Worked a treat

Obvious really - newbie screw up!!


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum