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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About to give up !

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Could someone please show me some code of how you assign a session to a dropdown array, so that when an item is selected it stays selected until the user clicks submit, even if they navigate back and forward, I'm new to this and need a clear explanation. After 4 days of trying to figure this out I am no closer

Tks

Graham
 
Can you post some code that you have tried so that we can tell you where you are going wrong. Thanks

If it aint broke, redesign it!
 
When you say "navigating back and forward", I assume you mean by hitting the "Back" and "Forward" arrows on the browser. If this is the case, you can't control what is displayed via PHP, since it is controlled by the browser. You might be able to do it with Javascript since that runs on the client. Until the use hits "Submit", PHP has no way of knowing what is displayed.

Even after the user hits "Submit" and then hits the "Back" button on the browser, PHP won't know of it.

The only way PHP will know of anything would be if your code displays a Submit button labeled "Back" or "Forward" and the user presses one of them. Then PHP can control what is being displayed.

Ken
 
Cool,

Having being trying for ages to get somewhere

Here is the code i am using to pull my info from my mysql
table. I just want to fix the sessions so that it retains the value selected in the field for the users to view in case they might want to change some options

----------------------------------------------------------------------------------------------------------------------

echo'<table align="center">';

echo'<tr>
<td colspan="2" class="labelcell"><label for="secondary_exam_id">Select Exam:</label></td>';

echo'<td colspan="2" class="fieldcell2">
<select name="secondary_exam_id">';

$query_result = mysql_query ('SELECT * FROM secondary_exam_type ORDER BY secondary_exam_id');

while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))

{
echo "<option value=\"$row[0]\">$row[1]</option>\n";
}



echo'</select></td>';

echo'</tr>';

----------------------------------------------------------------------------------------------------------------------
 
As I said in the other post, use sessions.
The session variable will work across browsers!

It will die if the browsers are closed.

It will also expire.

This will work as a login script, only that you will store non-vital data in the session variables.

Olav Alexander Mjelde
Admin & Webmaster
 
Ken

But all i want to do is have a page before my confirmation page giving the users one last chance to change their details before they submit, using my textboxes i can carry the variables to the final page but i cant carry the sessions of the dropdowns.

If you have a chance go to my site
login as below
username = test123
password = 161616

follow the 3 steps and you'll see what i mean
 
if you wish to carry the variables without sessions use:

<input type="hidden" name="variablename" value="$_POST['variablename']" />

Olav Alexander Mjelde
Admin & Webmaster
 
If I understand your problem correctly, you'll need to use Javascript. Something like the onchange() function is the only way that I know of to have the browser send information to the web server as soon as something is selected, rather than waiting until a button is clicked.
 
I've created a quick and dirty program that does what I think you want. You can try it out at
The source can be seen at
I use a session array to hold the selected values from each dropdown list which are then selected on the last page.

It may not be the best coding, but I wrote (& debugged it) in about 2 hours.

See if it makes sense and try to apply what I did to your problem.

Ken
 
When you generate the page (I'm assuming each is dynamic) you could get the currently selected value from session and while you are building the drop down list HTML, mark the current one as "selected".
something like
<select>
<option>uk</option>
<option>finland selected</option>
</select>
Can't vouch for the HTML working but the technique will.
Alternatvily Im sure JavaScript will let you select a row in a list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top