Marcos01 Posted October 31, 2008 Share Posted October 31, 2008 Hello, I have a form on 1 page which pulls questions from a database. I would like to display the hidden field. I dont know if i use the hidden field correctly. Thanks for your help echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" value="">'; $query1="Select * from formquestions where pagina=$currentpage order by questionnumber"; $result1=mysql_query( $query1) or die("question query certainly didn't work"); while ($row=mysql_fetch_array($result1)) { $query2="Select * from formresponse where pagina=$currentpage and questionnumber = ".$row[questionnumber]." order by responsenum"; $result2=mysql_query( $query2) or die("Response Query certainly didn't work"); while ($row2=mysql_fetch_array($result2)) { echo '<input type="radio" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'" />'.$row2['responsetext'].'<br />'; } echo '<br />'; } //hidden values per page echo '<input type="hidden" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'">'; //=========================================================== echo '<input type="submit" name="pageminus" value="previous">'; echo '<input type="submit" name="pageplus" value="next">'; echo '<input type="hidden" name="camefrom" value="'.$currentpage.'">'; echo '</form>'; Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/ Share on other sites More sharing options...
samshel Posted October 31, 2008 Share Posted October 31, 2008 it looks ok..what is the problem? Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679213 Share on other sites More sharing options...
Marcos01 Posted October 31, 2008 Author Share Posted October 31, 2008 I would like to display it. If the hidden field is used correctly, how do I display it correctly? Thanks Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679215 Share on other sites More sharing options...
samshel Posted October 31, 2008 Share Posted October 31, 2008 display it? couuld you please elaborate more ? "hidden" field is actually hidden and you cannot see it in browser, you can check it in View source though.. Sorry if i got u terribly wrong. Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679217 Share on other sites More sharing options...
Marcos01 Posted October 31, 2008 Author Share Posted October 31, 2008 I need to store it in the database. But before i do that i would like to display the value in the browser. Is that possible? Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679247 Share on other sites More sharing options...
samshel Posted October 31, 2008 Share Posted October 31, 2008 echo '<input type="hidden" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'">'.$row2['responsetext']; is this what ur looking 4 ? Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679250 Share on other sites More sharing options...
feidakila Posted October 31, 2008 Share Posted October 31, 2008 once the form is sent you can print it example: echo $_POST['name_of_hidden_input']; //maybe is $_GET, it depends on the method you used Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679251 Share on other sites More sharing options...
SeanHarding Posted October 31, 2008 Share Posted October 31, 2008 Oooo are you looking for the hidden fields value? <input type="hidden" name="myhiddenfield" value="whatever you want in here"> to retrieve the hidden field: echo $_POST['myhiddenfield']; I could be completely wrong tho... Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679255 Share on other sites More sharing options...
Marcos01 Posted October 31, 2008 Author Share Posted October 31, 2008 The form I use displays 2 to 4 questions max at the time. After I hit next, A new set of questions is displayed. Above that I would like to display the previous filled out data. So if this line of code is correctly: echo '<input type="hidden" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'">'; What would the code be to print/display it? Sorry if I wasn't clear enough. Thank you all for your help Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679267 Share on other sites More sharing options...
Marcos01 Posted October 31, 2008 Author Share Posted October 31, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679594 Share on other sites More sharing options...
Maq Posted October 31, 2008 Share Posted October 31, 2008 You need to pass these names somehow. Are you posting this to itself or another page? Anyway, I would put each field name in double array and pass it. Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679641 Share on other sites More sharing options...
Marcos01 Posted November 1, 2008 Author Share Posted November 1, 2008 You need to pass these names somehow. Are you posting this to itself or another page? Anyway, I would put each field name in double array and pass it. It is posted to itself. I am not sure on how to do this. Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679927 Share on other sites More sharing options...
Maq Posted November 3, 2008 Share Posted November 3, 2008 When you assign the hidden field name assign that same value to a double array. Array[$Q_num][$page]. Before you submit you need to create another hidden field and pass this array through. So when you submit the page to itself you can get the values/questions with $_POST from the array. Maybe someone has a better idea? Link to comment https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-681214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.