/    Sign up×
Community /Pin to ProfileBookmark

using function parameter as url parameter

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:

[code]
function handydetails(Id)
{
window.open(“handydetails.php?Id=” + Id + “”, “Handydetails”, “location=no, directories=no, menubar=no, scrollbars=yes, toolbar=no, status=no, width=786″”);
}
[/code]

and its called like this:

[code=php]
<a href=”javascript:handydetails(<?php echo urlencode($rchandys->Fields(‘nr’)) ?>);”><?php echo $rchandys->Fields(‘marke’); ?></a>
[/code]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 05.2004 — try this:
<i>
</i>window.open('handydetails.php?Id=' + Id ,'Handydetails','location=no, directories=no, menubar=no, scrollbars=yes, toolbar=no, status=no, width=786');
Copy linkTweet thisAlerts:
@tomhartlandNov 05.2004 — 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 ?
Copy linkTweet thisAlerts:
@tomhartlandNov 05.2004 — You beat me to it Kor...!?! ?
Copy linkTweet thisAlerts:
@KorNov 05.2004 — 
I'm forcing the number to a string for completeness
[/quote]

No need, I reckon... Adding a number to a string - the result is always a string.
Copy linkTweet thisAlerts:
@chzumbrunnenauthorNov 05.2004 — 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!
×

Success!

Help @chzumbrunnen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...