/    Sign up×
Community /Pin to ProfileBookmark

onclick(I think) coding assistance

I’ve got some code that I need to alter, but I’m far from knowing much about JS (total n00b). What I am trying to have done is that the page containing this link should navigate to [url]http://www.mypage.com[/url] and a new window should open up and navigate to a file called printanswers.php.

Here is the original code I have to change:

[CODE]if ($thissurvey[‘printanswers’]==’Y’)
{
$completed .= “<br /><br />”
.”<a href=’www.mypage.com’ target=’_self’ onClick=’window.open(‘printanswers.php’);’>Click here to print your answers </a>”
.”</a><br />n”;
}[/CODE]

Here is what I have come up with so far, but it’s not working.

.”<a href=’www.mypage.com’ target=’_self’ onClick=’window.open(‘printanswers.php’);’>Click here to print your answers </a>”

Any help would be greatly appreciated.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 26.2009 — &lt;a href="www.mypage.com" target="_self" onClick="window.open('printanswers.php'); location.href=this.href;"&gt;2windows&lt;/a&gt;
Copy linkTweet thisAlerts:
@mt_hillerauthorNov 26.2009 — &lt;a href="www.mypage.com" target="_self" onClick="window.open('printanswers.php'); location.href=this.href;"&gt;2windows&lt;/a&gt;
[/QUOTE]


So my overall code would look like this?:

[CODE]if ($thissurvey['printanswers']=='Y')
{
$completed .= "<br /><br />"
."<a href="www.mypage.com" target="_self" onClick="window.open('printanswers.php'); location.href=this.href;">Click here to print your answers</a>"
."</a><br />n";
}[/CODE]


?

Thanks,
Copy linkTweet thisAlerts:
@FangNov 26.2009 — If you escape the quotes correctly. ?

Don't use (double) break elements. Use css:&lt;a [COLOR="Navy"]style="display:block;margin:1em 0;"[/COLOR] href="www.mypage.com" ta ...
Copy linkTweet thisAlerts:
@mt_hillerauthorNov 26.2009 — If you escape the quotes correctly. ?

Don't use (double) break elements. Use css:&lt;a [COLOR="Navy"]style="display:block;margin:1em 0;"[/COLOR] href="www.mypage.com" ta ...[/QUOTE]


I'm learning...

So more like this?

[CODE]if ($thissurvey['printanswers']=='Y')
{
$completed .= "<br /><br />"
."<a style='display:block;margin;1em 0;' href='www.mypage.com' target='_self' onClick='window.open('printanswers.php'); location.href=this.href;'>Click here to print your answers</a>"
."</a><br />n";
}[/CODE]


I really, truly don't know wtf I'm doing ?

So thanks for your help!
×

Success!

Help @mt_hiller 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,
)...