Jump to content

Javascript Variables from Form


porzant

Recommended Posts

Yup, there is :)Make sure your element looks like this, note the id="":<input type="text" value="Input" id="txt" />This button makes it so that the text's value is sent to a javascript function, which I will just show you:<input type="button" value="Go!" onclick="val()" />Now, in the <head> section of your HTML document, add this:<script type="text/javascript">function val() { x=document.getElementById("txt").value; //Ok, now x contains the value of your form element.}</script>There ya go. :)

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...