|
|
Forms |
| You cannot use forms very well without using CGI. If you are making a simple form, however, JavaScript will definitely suffice. |
|
The HTML code to start a form is <form>. You also want to include a name in your form tag so that it can refferenced by your script.
The code for a form with a button, a text field, and a checkbox would look like this: <form name="form1"> <input type="button" name="button1" value="button"> <input type="text" name="text1" value="text"> <input type="checkbox" name="checkbox1"> checkbox </form> |
|
The actual form would look like this: |
| We're are going to make a simple password form. |
| Remember, the input tags must be inside of the <form> and </form> tags. |
| The value variable in the textfield represents the text that that field has in it. |
| The following shows how you would use input from a form to create a really pathetic security feature. |
the Confirm Function |
|
| The Confirm command brings up a small window in which the user can give a OK/Cancel response. | |
|
The code I used for the button was: <input type="button" onclick="javascript:var temp = confirm('pretty groovy, huh?');" value="See it in action!"> | |
|
The variable will be equal to true/1 if they hit OK or false/0 if they hit Cancel. | |
|
You can use an if statement to see if they hit ok or not i.e.:
var temp = confirm("Hit OK or Cancel"); if (temp == true) { alert('you hit OK'); } if (temp == false) { alert('you hit Cancel'); } |