www.webdeveloper.com
Results 1 to 3 of 3

Thread: pulling input text from a form ?

  1. #1
    Join Date
    Jun 2007
    Posts
    3

    pulling input text from a form ?

    I have the following code:

    Code:
    <SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
    <!--
    function post45 ()
      {
      alert(+ myForm.firstname.value +); 
       document.bgColor="#EEEEEE";
       }
    
    //-->
    </SCRIPT>
    
    <form name="myForm">
    	<table border="0">
    				<tr>
    			<td><label for="firstname">Firstname:</label></td>
    			<td><input type="text" name="firstname" id="firstname"></td>
    		</tr>
    		<tr>
    			<td></td>
    			<td><input type="button" value="Close" onclick="closeMessage()">
    			<input type="button" value="Send" onclick="post45(myForm)"></td>
    		</tr>
    	</table>
    	<script type="text/javascript">
    	document.myForm.firstname.focus();
    	</script>
    </form>
    I am trying to get the value entered into the firstname box appear on an alert box when the send button is pressed.

    With the above code the alert box dosnt display but if i take away the + myForm.firstname.value + from the java script it displays the alert box.

    Could someone please sugest a way i can get the + myForm.firstname.value + to display the entered value ?

  2. #2
    Join Date
    Jan 2010
    Posts
    10
    make ur alert like this and it will work

    Code:
    alert(myForm.firstname.value);

  3. #3
    Join Date
    Jan 2010
    Posts
    10
    U miss used the '+' in your code. It's only used to connect several lines/parts of code in one sentence like this:

    Code:
    alert("Hello " + myForm.firstname.value + ". Hope to hear from u soon " + myForm.firstname.value");

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles