Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP and javascript call problem

Status
Not open for further replies.

mlm823

Programmer
Oct 29, 2003
39
US
Hello

I'm trying to make a javascript call within a href tag inside a php file. The purpose is to open a new window with a certain page...

Here is the call statement

<tr><td>Survey Name:</td>
<td><img src=&quot;images/blank.gif&quot; width=&quot;5&quot; height=&quot;1&quot;><A
href=\&quot;javascript:DisplayHelp('SurveyName')&quot;\> <img src=&quot;images/QuestionMark.gif&quot; border=&quot;0&quot;></A><img src=&quot;images/blank.gif&quot; width=&quot;5&quot; height=&quot;1&quot;></td>

this is all in an echo statement.

Here is the javascript code
function DisplayHelp (helpTerm) {
if (helpwin) { helpwin.close(); }
var helpwin = window.open(&quot;showHelpTerms.php?SelectedTerm=&quot;+helpTerm&quot;, &quot;help&quot;,

&quot;directories=no,toolbar=no,menubar=no,location=no,resize=yes,status=no,resizable=yes,scrollba

rs=yes,width=465,height=275&quot;);
helpwin.focus();
}

Now when you highlight over the image it shows the javascript call with a wrong url.. and if you click the image nothing happens...

Any help is most appreciated.

Maranda
 
Your link has backslaches that shouldn't be there:
This:
&lt;A href=\&quot;javascript:DisplayHelp('SurveyName')&quot;\&gt;

Should be this:
&lt;A href=&quot;javascript:DisplayHelp('SurveyName')&quot;&gt;

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life=life-1};
 
THanks... but the window doesn't open...

Is there something wrong with my javascript code?

M
 
Try this:

var helpwin={closed:true}
function DisplayHelp (helpTerm) {
if(helpwin.closed){
helpwin = window.open(&quot;showHelpTerms.php?SelectedTerm=&quot;+helpTerm&quot;, &quot;help&quot;,&quot;directories=no,toolbar=no,menubar=no,location=no,resize=yes,status=no,resizable=yes,scrollbars=yes,width=465,height=275&quot;);
}
helpwin.focus();
}

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life=life-1};
 
It didn't seem to work with this change either.

I know that rather than doing the open window I can do an onclick within the image.

How would I do that?

Thanks,

Maranda
 
An onclick would be like this:
&lt;img src=&quot;images/QuestionMark.gif&quot; border=&quot;0&quot; onclick=&quot;DisplayHelp('SurveyName')&quot;&gt;

But that's not going to help unless you get your code working. I just noticed that your code has an extra &quot; in it. Try this:

var helpwin={closed:true}
function DisplayHelp (helpTerm) {
if(helpwin.closed){
helpwin = window.open(&quot;showHelpTerms.php?SelectedTerm=&quot;+helpTerm, &quot;help&quot;,&quot;directories=no,toolbar=no,menubar=no,location=no,resize=yes,status=no,resizable=yes,scrollbars=yes,width=465,height=275&quot;);
}
helpwin.focus();
}

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life=life-1};
 
I made the changes of getting rid of the extra &quot; and still not working so I tried to just do an alert and that didn't even work...

I'm thinking it might be a problem with the call since it is part of a php echo statement... wondering if I need to close php to make that call

Any ideas?
 
Well I got it to work... I had to take the call out of the php echo statement. Ironic thing.

It works now!

Thank you for all your advice and help!

Maranda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top