473,513 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to maintain the selected value of the drop down list after reloading it thrice?

2 New Member
i ve 2 dynamic drop down lists... after the user chooses a value in the first drop down ...the second list gets populated..this is done thru reloading... my prob is after reloading it once ,the value in the first list is maintained.... but after reloading it again for another operation... the value in the first list goes blank...only the second one is retained...how do i maintain all the selected values after reloading it thrice ?pls help :(
Aug 3 '10 #1
3 4353
TheServant
1,168 Recognized Expert Top Contributor
I think that you're relying on the browser to retain those "selected" values, which means that using different browsers (and possibly versions) you will get different results. The only way to reliably do this that I can think of is using sessions, but this is a bit overkill for simply retaining values.

When you "reload" what are you doing? Submitting a form? Pressing refresh? If you're submitting a form, then you could simply check if $_POST['value1'] has been set and set your value1 as that everytime the page loads. If you are hitting refresh, then you're actually asking your browser to reload everything as if you had not been there before, so only server side commands (like sessions) will retain values reliably.
Aug 3 '10 #2
zzzxxxyyy
2 New Member
Expand|Select|Wrap|Line Numbers
  1. echo "<SCRIPT language=JavaScript>";
  2. echo "function reload(form){
  3. var val=form.cat.options[form.cat.options.selectedIndex].value;
  4. self.location='dd1.php?cat=' +val;
  5. }";
  6.  
  7. echo "</script>";
m using the above code to reload the form.....so sessions is the best way is it..okie will try ...thanks a lot any way ..will keep askin my doubts :)
Aug 3 '10 #3
TheServant
1,168 Recognized Expert Top Contributor
No problem. Have you considered using AJAX to only reload parts of the form? Google it if you don't know what I'm talking about, but that only "refreshes" individual code blocks (for example everything in a specific div).
Aug 3 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
6587
by: deko | last post by:
I populate a drop-down list like this: echo "<select>"; foreach ( $ip_list as $var ) { echo "<option>"; echo $var; echo "</option>"; } echo "</select>";
2
2455
by: Serge Myrand | last post by:
Hi, I cannot get the selected option to be POSTed (it does not appear in the QueryString when using GET neither) I construct the drop down list from an array, I select an element in the list,...
4
6286
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
4
37447
by: charliewest | last post by:
I need to set the selected drop down list value at run time. I am aware of the method "SelectIndex" however this works only if you know the precise location of the value within the ListItem...
3
26260
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get...
2
12595
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
5
4204
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
1
1112
by: mrjoka | last post by:
hi, i have a label and i have two drop down list and i want to assign a value to this label when a value has been selected from drop down list 1(this one already working) now i want the label to...
3
7331
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the...
2
3316
by: crazychrisy54 | last post by:
Hi there I have a option, select drop down list which a user can open. My page however refreshes very frequently and when this occurs the selected drop down list will pop back up. The user then...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.