Notices

Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Passing a value from html to JavaScript

Post Reply New Thread Subscribe Search this Thread
 
 
Thread Tools
Old 10-03-01, 01:10 PM Thread Starter   #1
ipquix
New Member



Join Date: Sep 2001
Location: Iowa and Michigan

 
Unhappy Passing a value from html to JavaScript


I'm taking a class called internet programming and in it is a one month section of JavaScript. The only other language I've ever had was apple basic way back in junior high, so this is very very different. I am having trouble figuring out how to pass the value from my form in the html code to the function in the JavaScript. I've read the book, and there seems to be a million different ways to do it. Does anyone have any advice?
ipquix is offline   QUOTE Thanks
Old 10-03-01, 01:25 PM Thread Starter   #2
ipquix
New Member



Join Date: Sep 2001
Location: Iowa and Michigan

 
Here is an example. This is a simple program that /should/ work, everything I've read says it should work, all the examples I looked at say it should work, but the function still isn't getting the value, what am I doing wrong?

<html>
<head>
<title>Personalized Greeting</title>
<script language="JavaScript1.2">
<!-- hide from older browsers
function greet(hello)
{
if(hello == "y")
{
name=prompt("Please enter your name", "Enter your name here");
alert("Welcome "+name+"!");
}
else
{
alert("Welcome guest!");
}
}

// Stop hiding -->
</script>
</head>
<body>
<FORM NAME="Welcome">
Would you like to see a personalized greeting?<br>
<INPUT TYPE=radio NAME="yesOrNo" VALUE="y"
onClick="greet(this.value)">Yes<BR>
<INPUT TYPE=radio NAME="yesOrNo" VLAUE="n"
onClick="greet(this.value)">No<BR>
</FORM>
</body>
</html>

Last edited by ipquix; 10-03-01 at 01:48 PM.
ipquix is offline   QUOTE Thanks
Old 10-04-01, 04:57 AM   #3
Thelemac
Administratively Deficient

 
Thelemac's Avatar 

Join Date: Mar 2001
Location: Canton, MI

10 Year Badge
 
Quote:
Originally posted by ipquix
<html>
<head>
<title>Personalized Greeting</title>
<script language="JavaScript1.2">
<!-- hide from older browsers
function greet(hello)
{
if(hello == "y")
{
name=prompt("Please enter your name", "Enter your name here");
alert("Welcome "+name+"!");
}
else
{
alert("Welcome guest!");
}
}

// Stop hiding -->
</script>
</head>
<body>
<FORM NAME="Welcome">
Would you like to see a personalized greeting?<br>
<INPUT TYPE=radio NAME="yesOrNo" VALUE="y"
onClick="greet(this.value)">Yes<BR>
<INPUT TYPE=radio NAME="yesOrNo" VLAUE="n"
onClick="greet(this.value)">No<BR>
</FORM>
</body>
</html>
If you cut and pasted this code, then the part in bold is your problem, or at least part of it. Possilby also the caps. Not sure if Javascript is caps sensitive or not, but most languages are.

__________________
42 | Sig Assassin

*click*
Thelemac is offline   QUOTE Thanks

Post Reply New Thread Subscribe


Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Mobile Skin
All times are GMT -5. The time now is 08:05 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
You can add these icons by updating your profile information to include your Heatware ID, Benching Profile ID or your Folding/SETI profile ID. Edit your profile!
X

Welcome to Overclockers.com

Create your username to jump into the discussion!

New members like you have made this the best community on the Internet since 1998!


(4 digit year)

Why Join Us?

  • Share experience
  • Max out your hardware
  • Best forum members anywhere
  • Customized forum experience

Already a member?