Jump to content

problem with forms


132591

Recommended Posts

<form name="myform" id="myform"><input type="text" name="mytext" id="mytext" /><input type="submit" value="enter text" /></form><script type="text/javascript"><!--var text = document.myform.mytext.value;document.write(text);--></script>

Why does this not work?

Link to comment
Share on other sites

<form name="myform" id="myform"><input type="text" name="mytext" id="mytext" /><input type="submit" value="enter text" /></form><script type="text/javascript"><!--var text = document.myform.mytext.value;document.write(text);--></script>

Why does this not work?

It may becuase there is no submit type and no method in there try this:
<form name="myform" id="myform" method="get"><input type="text" name="mytext" id="mytext" /><input type="submit" value="enter text" onclick="showForm(this.form);"></form><script type="text/javascript"><!--function showForm(form1){for(var i=0; i<form1.length;i++){var text = document.getElementById('mytext').value;document.write(text);}}--></script>

Ok, over kill a little bit, but I only added the loop incase you have multiple inputs like name, day, country.. so on. Anyways you submit the form with the onclick event to the function showForm. anyways the variable text will get the data (note: use IDs with every input, becuase its easier to get using Jscript) of mytext.Then it simply prints out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...