/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Cannot get alert() to work

I want to use a button with an onClick(), but I am missing something in the syntax. For testing, I am using the alert() function. Can you point out what I am missing?

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd“>
<html>
<head>
<title>Test</title>
</head>
<body>
<input name=”btnOrder” type=”button” value=”Test” onClick=”alert(‘Hello'”)>
</body>
</html>

Feeling a little dumb,

Todd

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@tirnaApr 25.2010 — maybe try:

[CODE]
<input name="btnOrder" type="button" value="Test" onClick="alert('Hello');" />
[/CODE]
Copy linkTweet thisAlerts:
@rtcaryauthorApr 25.2010 — That works! However, when I go to the next step, open a window, my code is not working.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Test</title>

<script language="javascript" type="text/javascript">

<!--

function openWindow(theURL,winName,features) {

window.open(theURL,winName,features);

}

//-->

</script>

</head>

<body>

<input name="btnOrder" type="button" value="Order"

onClick="openWindow('hawk_order.php','ordWindow','toolbar=no,status=yes,scrollbars=no,resizable=no'" />

</body>

</html>
Copy linkTweet thisAlerts:
@FangApr 25.2010 — Missing closing bracket&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Test&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;
function openWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input name="btnOrder" type="button" value="Order"
onclick="openWindow('hawk_order.php','ordWindow','toolbar=no,status=yes,scrollbars=no,resizable=no'[COLOR="Red"])[/COLOR];"&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@rtcaryauthorApr 25.2010 — Fang - First, thank you! Second, my apologies. I consider this site to be a valuable resource, so I kick myself when I take "bandwidth" with dumb mistakes.

Todd
Copy linkTweet thisAlerts:
@rtcaryauthorApr 25.2010 — Fang -

Could you check my new post where I took the code that you helped me get working and placed it into a php page. There it does not work. Baffled!!

Todd
×

Success!

Help @rtcary 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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