Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   Using form text values? (http://www.programmingforums.org/showthread.php?t=12928)

Phonetic Apr 3rd, 2007 2:24 AM

Using form text values?
 
<head>
<script type="text/javascript">

function heh() {

var rawr = getElementById("name")

if ("name == tyler")
alert("Wow kid you're a little faggot!")
}
else("name == * ")
}
}
</script>
</head>
<body>
<form>
ENTER YOUR NAME!!!<input type="text" id="name" value="">
<input type="submit" value="CLICK ME!" onclick="heh()">
</form>
</body>

Sigh I was wondering if anyone would know how to take the value information from the text input and use it to create and alert, or just to call on the information whenever I need it? This is a script I put together to show what I thought would be how it's done, but it's not. Anyway can someone help me?

Ooble Apr 3rd, 2007 2:39 AM

OK, let's take a look at your code:

:

<script type="text/javascript">
<!--
function heh() {
    var rawr = getElementById("name");
    if (rawr.value == "tyler")
    {
        alert("Wow kid you're a little faggot!");
    }
    else
    {
        rawr.value = "*";
    }
}
// -->
</script>


Compare the two. And in future, please use [code] tags to make your code easier to read.

Arevos Apr 3rd, 2007 7:12 AM

Shouldn't that be document.getElementById?

Also, semicolons aren't strictly necessary in ECMAScript.

Finally, could we perhaps in future refrain from using potentially offensive profanity in examples? Thanks :)

Ooble Apr 6th, 2007 8:53 AM

Apologies - failed to spot that one. And no, they're not, but damn, do they make things easier to read. :)


All times are GMT -5. The time now is 2:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC