Click to See Complete Forum and Search --> : Need Help!!!!


Dr1ft3r
12-03-2002, 07:09 PM
Hey whats up i need help with a little javascript....nothing really hard for you javascripters, but im not yet a professional on the matter and i was wondering if i could get a little help....i want a user to type a word in a text field and then when they press a "Submit" button it will detect what the first letter of the word is and insert it into a variable...if anyone could help me out with the code i would surely appreciate it....thanks in advance

MikeOS
12-03-2002, 07:39 PM
Try the script below. I included the alert method in the function just to show that it works.

<html>
<head>
<script language="javascript">
var theletter;
function getletter(theform)
{
theletter = theform.whatever.value.substring(0,1)
alert(theletter)
}

</script>
</head>
<body>
<form name="myform">
<input type="text" size="30" name="whatever"><br>
<input type="submit" value="Send" onclick="getletter(this.form)">
</form>

</body>
</html>

Dr1ft3r
12-04-2002, 02:13 PM
thanks alot...:D