JavaScript Tutorial/Form/Action

Материал из Web эксперт
Перейти к: навигация, поиск

Form action: javascript:alert

   <source lang="javascript">

<html>

   <head>
       <title>Submit Example</title>
   </head>
   <body>
       <form id="form1" method="post" action="javascript:alert("Submitted")">
           
           <label for="txtName">Name:</label>
<input type="text" id="txtName" name="txtName" />
<input type="button" value="Submit Form" onclick="document.forms[0].submit()" /> </form> </body>

</html></source>


Get form action value

   <source lang="javascript">

<html> <head> <title>Online Survey</title> </head> <body> <form action="http://www.wbex.ru" method="POST" name="MyForm">

wbex.ru - Online Survey

Your Name:   <input type="text" name="YourName"/>
Your Gender:  
  <input type="radio" name="Gender" value="Male"/>Male
<input type="radio" name="Gender" value="Female"/>Female
Which of our consultancy
services are you interested in?
 
  <input type="checkbox" name="Java"/> Java
<input type="checkbox" name="Javascript"/> Javascript
<input type="checkbox" name="SVG"/> SVG
<input type="checkbox" name="XSL-FO"/> XSL-FO
<input type="checkbox" name="ASP.Net"/> ASP.Net
Which free gift would you prefer for filling out this survey?  
 <select name="FreeGift">
  <option value="Choice1">AAA</option>
  <option value="Choice2">BBB</option>
  <option value="Choice3">CCC</option>
 </select>
Enter your comments in
the text box
  <textarea name="Comments" rows="5" cols="50"> </textarea>
   
<input type="submit" value="Send Form"/>

</form> <script type="text/javascript" language="javascript">

</script> </body> </html></source>