Okay I'm at work so thats why I have not searched through the forum so I hope you don't go to hard on me (I know I usually flame people for that). Anyway what I am trying to do is enter data into a set of text boxes and have that info ran through a function in javascript. I made a simple demo just to see if I could even do this and have so far failed. I was hoping someone could help.

<form>
<input="text" name="my">
<input type="button" value="Submit" onclick="dude()">
</form>
(Incidentally, I changed the input button from a submit button to a generic button in order to prevent it submitting in this demo.)

_Aerospace_Eng_

05-03-2006, 11:57 PM

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function dude()
{
//this gets the value, forms[0] represents the first form on the page
theText = document.forms[0].my.value;
//you can also use document.getElementById(), the input needs to have id="..."
theTextById = document.getElementById('my').value;
alert("This uses the name of the input: " + theText);
alert("This uses the id of the input: " + theTextById);
//this prevents the form from actually being submitted but still allowing use to hit enter or submit
return false;
}
</script>
</head>

Bill beat me to it
Codes are similar but a bit different I prefer the submit button just because users can still hit the enter key or submit button.

DenKain

05-04-2006, 12:47 AM

Thank you so much that worked great. The thing is I applied that to the actual script I was making and it is having a separate issue. As you may notice when you run it the function starts even when it is not called to. Any ideas??