maha_kaal

Basic JS function to check form

Mar 11th, 2011
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.38 KB | None | 0 0
  1.     <html>
  2.     <head>
  3.     <script language="javascript" type="text/javascript">
  4.     <!--
  5.    function controlla() {
  6.    //prendo il valore di ogni option
  7.    for( i = 0; i < 3 ; i++)
  8.    {
  9.            if (optform.opt[i].checked)
  10.            {
  11.                          
  12.                    switch(optform.opt[i].value)
  13.                    {
  14.                            case \'update\':
  15.                            alert("update");
  16.                            break;
  17.                            case \'delete\':
  18.                            alert("delete");
  19.                            break;
  20.                            case \'insert\':
  21.                            alert("insert");
  22.                            break;
  23.                    }      
  24.       }
  25.    }
  26.    }
  27. function showHide(id)
  28. {
  29. if (id.style.display != 'block')
  30. id.style.display = 'block';
  31. else
  32. id.style.display = 'none';
  33. }
  34.    //-->
  35.     </script>
  36.     <style type="text/css">
  37.      
  38.     </style>
  39.     </head>
  40.     <body>
  41.     <center>
  42.     <form name="optform">
  43.     <label>Aggiorna</label><input type="radio" value="update" name="opt" /><br>
  44.     <label>Elimina</label>   <input type="radio" value="delete" name="opt" /><br>
  45.     <label>Inserisci</label> <input type="radio" value="insert" name="opt" /><br>
  46.     <input type="button" value="vai!" onClick="controlla()" />
  47.     </form>
  48.     </body>
  49.     </html>
Advertisement
Add Comment
Please, Sign In to add comment