Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php drop-down

Status
Not open for further replies.

jefargrafx

Instructor
May 24, 2001
273
0
0
US
I've created an html drop down that is populated via an sql qurry.

simple

the select field is name in_review

and I have a onChange="this.form.submit(); which submits the form to the same php page. Okay that'll work if I use hidden field to hold the results, but I'd like the drop down to remember it's selection.

how is this done? $HTTP_GET_VARS['in_view'];

any help?

jef
 
jef,

If you can collect the selected field in PHP ( I'd do this:
Code:
$in_view=$_REQUEST["in_view"];
). Then you can add selected="selected" in the option tag for the selected option...

Good Luck §;O)


Jakob
 
Can you elaborate a bit...I'm got a similar problem..
I've got a drop down box that the user completes. After completing the form, the user hits the submit button and the application lets him/her know what fields haven't been completed properly. The problem is that even though I've completed the drop down box field (in this case, it's the state), the state doesn't appear on the screen when the form is called again. Help!!!!
 
here's how I fixed it

<select name=&quot;in_review&quot; id=&quot;in_review&quot;onChange=&quot;this.form.submit();&quot; >
<?php
do {
?>
<!-- <option value=&quot;<?php //echo $row_rs_in_review['code']?>&quot;<?php //if (!(strcmp($row_rs_in_review['code'], $row_rs_in_review['code']))) {echo &quot;SELECTED&quot;;} ?>><?php //echo $row_rs_in_review['code']?></option>-->
<option value=&quot;<?php echo $row_rs_in_review['code']?>&quot;<?php if (!(strcmp($HTTP_POST_VARS['in_review'], $row_rs_in_review['code']))) {echo &quot;SELECTED&quot;;} ?>><?php echo $row_rs_in_review['code']?></option>
<?php
} while ($row_rs_in_review = mysql_fetch_assoc($rs_in_review));
$rows = mysql_num_rows($rs_in_review);
if($rows > 0) {
mysql_data_seek($rs_in_review, 0);
$row_rs_in_review = mysql_fetch_assoc($rs_in_review);
}
?>
</select>


notice the $HTTP_POST_VAR['in_review'], it works great accept when the page is first displayed.

so in the head I added

$in_review = $in_review


it's a hack, but working



also, on the $_REQUEST['field']

does this work even on the same page when posting back to itself? very cool

jef
 
Excellent! Yes, it works on the same page.

§;O)


Jakob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top