Javascript string problem

They have: 218 posts

Joined: Apr 2001

If I append a string userID value:

interactive.php?userID=EM

...javascript stops working, causing a new window not to open:

However, this works:

interactive.php?userID=99

Do I have to convert the string value in the first case so javascript is able to interpet it?

Thanks,

TonyMontana

druagord's picture

He has: 335 posts

Joined: May 2003

Did you try it in netscape or mozilla with the javascript console this help a lot for javascript errors. if you don't have it post a link or some code

IF , ELSE , WHILE isn't that what life is all about

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I would take it like this, though lord knows I don't do everything the "right" way:

<?php
&lt;script type=\"text/javascript\"&gt;
var userID = =
$userID;

// rest of your JavaScript
&lt;/script&gt;
?>

How are you doing it?

They have: 218 posts

Joined: Apr 2001

I figured this one out.

Here's the code that didn't work:

<?php
echo \"<a href='javascript:initWindow($userID, 0);'> etc...
?>

And here is a version that does:

<?php
echo \"<a href=\\"javascript:initWindow('$userID', 0);\\"> etc
?>

Those kinds of quote errors are really annoying. Wink

TM

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

heh, yeah, they are poopy. hence my use of <?= ?>

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.