Jump to content

Hidden field in form


nutstretch

Recommended Posts

I am working on an application where the user can check to see if someone has registered and if so use thier details to make a booking.  I want to use a dropdown list in a form which allows the user to check name and email address as these are the fields i am using to make sure it is a unique person.  I am populating the form with the list of registrants and want to make a hidden field which holds the bookingid.

 

The problem I am having is that it is bringing through the client id but not the booking id.  I have no problems with this if it is in html but for some reason it is not working here.

 

code from form - courseid defined above this

   print "<form name='Clients' method='post' action='justtesting.php'>";
   print "<input type='HIDDEN' NAME='bob' VALUE='$courseid'>";

print "<p>Search by Client Name<p>";
    print "<select name='client' size='1' style='WIDTH: 80%' onchange='this.form.submit()'  >";
     print   "<option value='clientname' selected>Choose Client</option>";
 while ($row1 = mysql_fetch_assoc($resultID))
			{
			$item = $row1['name'];
			$value = $row1['clientID'];
			$desc = $row1['email'];
print    "<option value='$value'>$item : $desc</option>";
					   }
					   		  print" </select>";

    print "</form>";

 

code from process form

<?php 
$courseid = $_POST['bob'];
$clientid = $_POST['client'];
print "$courseid ,  $clientid ";

	?>

 

Anyone who can shed alight on what i have done wrong would be revered higher than ice cream in my estimations and that is pretty high already

 

Nuts

Link to comment
https://forums.phpfreaks.com/topic/125280-hidden-field-in-form/
Share on other sites

My guess is that you want the selected course id to be stored in the hidden variable.

 

For that you have to assign the hidden variable "bob" with the selected course value using javascript. and this should done on the onclick event of the submit button

 

Link to comment
https://forums.phpfreaks.com/topic/125280-hidden-field-in-form/#findComment-647580
Share on other sites

sorry I am not sure what you mean. 

 

Usually if I am doing a html form  extra values I need to carry over are just added as hidden values in the form. 

 

That is what i have done here but is not readying it on the next page.

 

I am not sure why i have to use javascript?

 

sorry if i am appearing thick

Link to comment
https://forums.phpfreaks.com/topic/125280-hidden-field-in-form/#findComment-647595
Share on other sites

Yes I do and i have given $courseid a value earlier.  What I need to do is carry that and the value from the drop down box across to my next page which will process both.  In HTML I just add that value to a hidden field so that on my next page I can $courseid = $_POST['courseid'];  it.

 

But when i have put it into the php it is not bringing the value across.

print "<input type='HIDDEN' NAME='bob' VALUE='$courseid'>";

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/125280-hidden-field-in-form/#findComment-647637
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.