Page 1 of 1

Invalid assignment error

Posted: Tue Sep 06, 2011 4:18 am
by social_experiment
I want to add a second value to a query string but keep getting this error message:

Error: invalid assignment left-hand side
Source Line: 2, Column: 52
Source Code: options[form1.city.options.selectedIndex].value&id=2','chooseBox')

This is the php code that creates the javascript which yields the error above

Code: Select all

<?php
echo ' <img src="img/big_cloud.png" 
onclick="callAHAH(\'test11.php?city=\'+form1.city.
options[form1.city.options.selectedIndex].value&id=2\',\'chooseBox\')" height="75" width="75" 
alt="Click here" title="Click for info" />';
?>

Invalid assignment error

Posted: Tue Sep 06, 2011 4:19 am
by social_experiment
I want to add a second value to a query string but keep getting this error message:

Error: invalid assignment left-hand side
Source Line: 2, Column: 52
Source Code: options[form1.city.options.selectedIndex].value&id=2','chooseBox')

This is the php code that creates the javascript which yields the error above

Code: Select all

<?php
echo ' <img src="img/big_cloud.png" 
onclick="callAHAH(\'test11.php?city=\'+form1.city.
options[form1.city.options.selectedIndex].value&id=2\',\'chooseBox\')" height="75" width="75" 
alt="Click here" title="Click for info" />';
?>

Re: Invalid assignment error

Posted: Wed Sep 07, 2011 3:16 pm
by twinedev
Looks like you left off a plus and opening quote after a variable to concatenate it to the string following:

form1.city.options[form1.city.options.selectedIndex].value&id=2

I think you may want to be:

form1.city.options[form1.city.options.selectedIndex].value+\'&id=2

-Greg

Re: Invalid assignment error

Posted: Wed Sep 07, 2011 3:45 pm
by twinedev
Well, I did reply.. don't know where it went... Guess I'll resubmit it ;-)
Somehow, his post got duplicated, so I've merged the 2 topics. [Mod]

When you are concatenating the strings with the variables as your parameters to callAHAH, you rammed them together at the end, leaving out the + and opening quote:

form1.city.options[form1.city.options.selectedIndex].value&id=2

form1.city.options[form1.city.options.selectedIndex].value + \'&id=2

-Greg

Re: Invalid assignment error

Posted: Thu Sep 08, 2011 5:02 am
by social_experiment
Thanks for the help :)

Re: Invalid assignment error

Posted: Thu Sep 08, 2011 1:38 pm
by twinedev
LOL, and today both replies are there.... Weird... Glad to help though.