Click to See Complete Forum and Search --> : using function parameter as url parameter


chzumbrunnen
11-05-2004, 02:07 AM
I list the resultset from a db query and want to link to the detail page.
Of course I have to pass the id as an URL parameter to the detail page.
Now because I want to open the detailpage in a separate window I use JavaScripts window.open function.
I tried it with a function to which the Id is given as a parameter but I can't reuse it or append the variable value to the pagename.

What is wrong?

My function looks like this:

function handydetails(Id)
{
window.open("handydetails.php?Id=" + Id + "\", \"Handydetails\", \"location=no, directories=no, menubar=no, scrollbars=yes, toolbar=no, status=no, width=786\"");
}


and its called like this:


<a href="javascript:handydetails(<?php echo urlencode($rchandys->Fields('nr')) ?>);"><?php echo $rchandys->Fields('marke'); ?></a>

Kor
11-05-2004, 02:33 AM
try this:

window.open('handydetails.php?Id=' + Id ,'Handydetails','location=no, directories=no, menubar=no, scrollbars=yes, toolbar=no, status=no, width=786');

tomhartland
11-05-2004, 02:35 AM
Why have you used \" ?
\" is used in a string to denote the literal quotes character - which is not what you want in this situation.

Try this... (I'm forcing the number to a string for completeness)function handydetails(Id)
{
window.open("handydetails.php?Id=" + Id.toString(), "Handydetails", "location=no, directories=no, menubar=no, scrollbars=yes, toolbar=no, status=no, width=786");
}Tom :)

tomhartland
11-05-2004, 02:36 AM
You beat me to it Kor...!?! :)

Kor
11-05-2004, 03:20 AM
I'm forcing the number to a string for completeness

No need, I reckon... Adding a number to a string - the result is always a string.

chzumbrunnen
11-05-2004, 06:14 AM
thanks, I tought I must be just a little off the right answer but sometimes I can't see the obvious.

Now - finally - it works as expected!