Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
help with javascript needed
Old 04-08-2005, 02:02 PM help with javascript needed
Guerrilla's Avatar
Ultra Talker

Posts: 424
Trades: -1
Hello,

Im trying to learn how to integrate javascript with forms so i wrote this script to display on screen in an alert box which number you click just as a test but it doesnt work and it doesnt generate an error in ie6 so im a bit stuck as to why it doesnt work.

I'd be very grateful if someone could share a bit of their wisdom with me.

Thanks

BEGIN CODE:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Form Button Test</title>
<script type="text/javascript">

function calculate(whichbox){
if (whichbox = 1);
alert("value is 1");
else (whichbox = 2);
alert("value is 2");
else (whichbox = 3);
alert("value is 3");
else (whichbox > 3);
alert("error value higher than 3");
else (whichbox < 3);
alert("error value less than 3");
}

</script>

</head>

<body>
<form>
<input name="one" type="submit" id="1" value="1" onClick="calculate(1)">
<input name="two" type="submit" id="2" value="2" onClick="calculate(2)">
<input name="three" type="submit" id="3" value="3" onClick="calculate(3)">
</form>
</body>
</html>
Guerrilla is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-08-2005, 03:57 PM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Trades: 0
It haven't worked in Firefox either. I see that you have no idea about JavaScript and even about programming at all, so better learn sth about operators and syntax in JS.

Your code:

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Form Button Test</title>
<script type="text/javascript">

function calculate(whichbox)
{
if (whichbox == 1)
  alert("value is 1");
else if (whichbox == 2)
  alert("value is 2");
else if (whichbox == 3)
  alert("value is 3");
else if (whichbox > 3)
  alert("error value higher than 3");
else if (whichbox < 3)
  alert("error value less than 3");
}

</script>

</head>

<body>
<form>
<input name="one" type="submit" id="1" value="1" onClick="calculate(1); return false;">
<input name="two" type="submit" id="2" value="2" onClick="calculate(2); return false;">
<input name="three" type="submit" id="3" value="3" onClick="calculate(3); return false;">
</form>
</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 04-08-2005, 06:29 PM
Guerrilla's Avatar
Ultra Talker

Posts: 424
Trades: -1
I'm just trying to pick it up. I'm sure you were a beginner once too. Thanks for the help, ill check my syntax more carefully before posting again.

Guerrilla is offline
Reply With Quote
View Public Profile
 
Old 04-08-2005, 06:41 PM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Trades: 0
Quote:
I'm sure you were a beginner once too.
Yeap. Everyone was. But before you post your problem i here you should have a little knowledge in the topic
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Reply     « Reply to help with javascript needed
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17547 seconds with 12 queries