nutstretch Posted September 22, 2008 Share Posted September 22, 2008 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 More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 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 More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 Javascript: document.Clients.bob.value = document.Clients.client[document.Clients.client.selectedIndex].value [/code[ Link to comment https://forums.phpfreaks.com/topic/125280-hidden-field-in-form/#findComment-647584 Share on other sites More sharing options...
nutstretch Posted September 22, 2008 Author Share Posted September 22, 2008 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 More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 ok ok .. Let me ask you what is the value of $courseid that you are assigning to hidden filed bob. what are you actually trying to do. I thought you want to assign the selected value to the hidden field. Link to comment https://forums.phpfreaks.com/topic/125280-hidden-field-in-form/#findComment-647603 Share on other sites More sharing options...
nutstretch Posted September 22, 2008 Author Share Posted September 22, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.