CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   HTML & CSS (http://www.codingforums.com/forumdisplay.php?f=13)
-   -   HTML form question (http://www.codingforums.com/showthread.php?t=266436)

brood_snow 06-27-2012 01:55 PM

HTML form question
 
Code:

<html>
                <head>
                <title>Student to search into database</title>

        <script language="javascript">
                        function validate2(objForm){
                               
                                int k = 0;
                                if(objForm.name.value.length==0){
                                        objForm.name.focus();
                                        k++;
                                }
                               
                                if(objForm.year.value.length==0){
                                        objForm.year.focus();
                                        k++;
                                }

                                if(objForm.id.value.length==0){
                                        objForm.year.focus();
                    k++;
                                }
                               
                                if(k == 0){
                                  return false;
                                }
                        return true;
                        }
          </script>
         
        </head>
                <body bgcolor=#ADD8E6><center>
               
                <form action="FoundStudents.jsp" method="post" name="entry" onSubmit="validate(this)">
               
                <input type="hidden" value="list" name="seek_stud">
                <table border="1" cellpadding="5" cellspacing="5" bgcolor = #333366>
                        <tr>
                                <td>
                                        <table>
                                                <tr><td colspan="2" align="center"><h2><font color= #FFFF66>Please insert student data</font></h2></td></tr>
                                                <tr><td colspan="2">&nbsp;</td></tr>
                                                <tr><td><font color= #FFFF66>Name:</font></td><td><input name="name" type="text" size="50"></td></tr>
                                                <tr><td><font color= #FFFF66>Year:</td><td><input name="year" type="text" size="50"></td></tr>
                                                <tr><td><font color= #FFFF66>ID:</td><td><input name="id" type="text" size="10"></td></tr>
                                                <tr><td colspan="2" align="center"><input  name= "submit_seek_stud" type="submit" value="Submit"></td></tr>
                                        </table>
                                </td>
                        </tr>
                </table>
                </form>
                </body>
  </html>

The form works only with the
Code:

<input type="hidden" value="list" name="seek_stud">
. Could someone please explain me why is this line necessary(what does it actually do)? Because I found on Google that hidden is used only when you submit some information(not visible to the user) in addition to what the user types, and I am not sending such additional information. :confused:

Thank you in advance!

DrDOS 06-27-2012 02:53 PM

I've used a hidden input for the isset statement in PhP when I had different forms with different inputs that all submitted to the same page. That way they could all use the same isset statement. But it can be used the other way too, so that you could distinguish between different pages that all use the same basic form. And it may get it's value from some javascript code somewhere else on the page.


All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.