/    Sign up×
Community /Pin to ProfileBookmark

java script beginner-please help, eit for school!

Dear All!
i have probelms with the program!
These are 3. functions.
Click on each button shoul dgive alert box with different text.
It happens allways the third one!
The4y tol dme to pass variables to a fundciton.
How to do that=
?
Here is the program!
Please help who can!
Regards,
M

<script type=”text/javascript”>
function myfunction(){alert(“A dog”);}
</script>
<form><input type=”button” onclick=”myfunction()” value=”a)”></form>
<br>

<script type=”text/javascript”>
function myfunction(){alert(“A cat “);}
</script>
<form><input type=”button” onclick=”myfunction()” value=”b)”></form>

<script type=”text/javascript”>
function myfunction(){alert(“A mouse”);}
</script>
<form><input type=”button” onclick=”myfunction()” value=”C”></form>
?

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@mrhooJan 30.2009 — give your functions different names, or use a single function that returns different values from different targets.
Copy linkTweet thisAlerts:
@marijaauthorJan 30.2009 — many thanks for Your answer!

the problem is I dont know how to do it!

What is the most simple way for beginner? I just started the day before yesterday, after that di dnto move cuase it jsut costs too much time!

Can U just tell me what is the simplest way so that I know what to concentrate to?

Many thanks!

M?
Copy linkTweet thisAlerts:
@skywalker2208Jan 30.2009 — You posted the same thing here and it is spelled out pretty clear of what you need to do and why you are getting your results.
Copy linkTweet thisAlerts:
@MaydayJan 30.2009 — Skywalker and I both offered solutions to this same question by you the other day on your previous thread:

http://www.webdeveloper.com/forum/showthread.php?t=200827&page=2

His solution was PRECISELY what you're asking:
[code=php]<script type="text/javascript">
function myfunction(mystring)
{
alert(mystring);
}
</script>
<form>
<input type="button" onclick="myfunction('string1')" value="a)">
</form>

<form>
<input type="button" onclick="myfunction('string2')" value="b)">
</form>

<form><input type="button" onclick="myfunction('string3')" value="c)">
</form> [/code]
Copy linkTweet thisAlerts:
@MaydayJan 30.2009 — Skywalker, we meet again! And under the same circumstances. lol

?
Copy linkTweet thisAlerts:
@marijaauthorJan 30.2009 — Dear All!

THANK U SO MUCH!

I DID IT!!!

www.practising.synthasite.com

and all on my third day with js!

POOR U ALL WITH MY NEXT DAYS!!!

HUGS TO ALL! U ARE THE BEST!!!

yR BEGINNER!
Copy linkTweet thisAlerts:
@marijaauthorJan 30.2009 — How does computer connect in its brain mystring with string1, string2, string3?

is that because of the "string" both words contain? Or does he just understand the system string+number and my, and string?
Copy linkTweet thisAlerts:
@marijaauthorJan 30.2009 — NO. It just conect mystring with the content in the small bracket!
×

Success!

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