How to make the details entered by any user in the form show as an alert?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Busola David

    How to make the details entered by any user in the form show as an alert?

    Code:
    </table><br/>Fill in your details below.<br/><br/>
    <form name="input" action="html_form_action.asp" method="get">
    
    <table width="337" border="0">
      
      <tr>
        <td width="103" height="22">First name:</td>
        <td width="224"><input type="text" name="Firstname" /></td>
      </tr>
      <tr>
        <td>Last name:</td>
        <td><input type="text" name="Lastname" /></td>
      </tr>
      <tr>
        <td>Address:</td>
        <td><input type="text" name="Address" /></td>
      </tr>
      <tr>
        <td>E-mail:</td>
        <td><input type="text" name="E-mail" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
    
    
         <td><script type="text/javascript">
    	function myfunction(txt)
    	{
    		alert(txt);
    	}
    	</script>
        <input onclick="checkCookie()" value="Submit" type="button"></td>
    </tr> 
    </table>
    Last edited by Dormilich; Oct 5 '10, 12:39 PM. Reason: please use [code] [/code] tags when posting code
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    what exactly should happen - and when should it happen?

    Comment

    • thesmithman
      New Member
      • Aug 2008
      • 37

      #3
      are you looking for something like this?

      Code:
      function myfunction(){
      checkCookie();
      var inputs = array('Firstname', 'Lastname', 'Address');//et cetera
      for(var i in inputs){
      alert(document.forms[0].inputs[i].value);
      }
      }
      I included your call to checkCookie within the function that alerts all the values. Then you would just have to change your submit button to:

      Code:
      onclick="myfunction()"

      Comment

      Working...