/    Sign up×
Community /Pin to ProfileBookmark

Alert box Problem

Hello to All:
I am new to java script, so this problem that I have should be easy for you guys and gals to solve.?

Ok, here is my problem with the alert method: I am having a rough time trying to find the correct sytax that will create an Alert box with the words that the users enters in to the text box? In other words, I want to make the words the user enters inside a text box on web-page display on to the Alert box after the user leaves the text field. I have inserted the onchange which does make the alert box appear, however, the Alert box will show the word that the user types in. Below is a code that I have so far.

<script type=”text/javascript”>
<!–
function contactInformation()
{

alert(“Your Name: ” + )
}
//–>
</script>

<input type=”text” name=”name” size=”50″ id=”name” onchange=”contactInformation ()” />

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleJan 31.2008 — You have to tell it to do so.
<i>
</i>&lt;script type="text/javascript"&gt;
&lt;!--
function contactInformation(text)
{

alert("Your Name: " + text)
}
//--&gt;
&lt;/script&gt;

&lt;input type="text" name="name" size="50" id="name" onchange="contactInformation (this.value)" /&gt;
Copy linkTweet thisAlerts:
@gil_davisJan 31.2008 — I am new to java script[/quote]
&lt;script type="text/javascript"&gt;
&lt;!--
function contactInformation([color=red]st[/color]) {
alert("Your Name: " + [color=red]st[/color])
}
//--&gt;
&lt;/script&gt;
&lt;input type="text" name="name" size="50" id="name" onchange="contactInformation([color=red]this.value[/color])"/&gt;

BTW, it is a bad idea to use a reserved word (e.g.: name) for an identifier. You never know when it will bite you. ?
Copy linkTweet thisAlerts:
@RecencyauthorJan 31.2008 — ThankYou, ThankYou, Thankyou Jason and Gil:

The Alert message is working great. I am truely greatful in that I have searched many, many javascript sites for hours looking for the correct syntax. I have found "this.value" syntax, however, I have used it without the text and of course it did not work. Thanks for the tip on the ID-name. I must have spent about 2hours trying to work that name into the arguments instead of the text. I will definitely stay away from that id-name from now on.

Thanks again- and Talk to you again most probable.

Recency
×

Success!

Help @Recency 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.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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