/    Sign up×
Community /Pin to ProfileBookmark

javascript open.window() problem. Includes use of php and sql

I have been struggling with a problem regarding the open.window function. I have a query which returns a list of names and i have made a list of a href links. See below…

[CODE]
$query = “SELECT DISTINCT Name FROM Comp2 WHERE Lower(Name) LIKE lower(‘%$name%’) ORDER BY Name”;
$qry_result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($qry_result)){
$url = str_replace(” “,”_”,$row[Name]);
echo $url;
$display_string .= “<a href=’javascript:openwindow($url)’>$row[Name]</a><br />”;
$count++;
}
[/CODE]

the above seems to work but the function openwindow() seen below does nothing but make an error on the page.

[CODE]
<script type=’text/javascript’>
function openwindow(url) {
alert(url);
var link = ‘http://www.myurl.co.uk/getresults.php?name=’ + url;

window.open(link,’new’,’toolbar=no,location=no,directories=no, status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=1000,height=400′);
};
</script>[/CODE]

If anyone could point me in the right direction to getting this solved that would be amazing, i would be greatly appreciative. Thankyou in advance!

Jonny

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@J2NYCMar 30.2009 — I gave this a try, replacing your url with stuff that works on one of my system. It works for me.

Try putting an alert on the link and checking to make sure there are no extraneous quotes.
Copy linkTweet thisAlerts:
@jonnyboy2authorMar 30.2009 — i still cant get it to work, if i make the variable $url an empty string it executes the function but uses undefined in place of the passed url. So obviously there is still somethign wrong with using a string variable with the function. Its not even letting me define $url as a standard 'hello'. Thank you again
Copy linkTweet thisAlerts:
@jonnyboy2authorMar 30.2009 — It also works when defining $url as an integer. :S
Copy linkTweet thisAlerts:
@jonnyboy2authorMar 30.2009 — got it working, i didnt have " " around the string when calling the function. needed to add some backslashes. I was almost sure i had already tried this and failed but oh well. Thanks anyway
×

Success!

Help @jonnyboy2 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.25,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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