Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    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.

    Thank you in advance!

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,903
    Thanks
    15
    Thanked 226 Times in 226 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •