473,573 Members | 3,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

drop down sticky in php

13 New Member
I am trying to make drop down stick in my php. Below is my code, can some one help me to make it sticky. I am tried and lost. I have two dropdown in the form, each pulls data from mysql with condition OnChange(),

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.  
  3. function autoSubmit()
  4. {
  5.     var formObject = document.forms['theForm'];
  6.     formObject.submit();
  7. }
  8.  
  9. </script>
  10.  
  11. <form name="theForm" method="post">
  12.  
  13. <?
  14. $code_query = "select customer_code from customer";
  15. $result = mysql_query($code_query);
  16. ?>
  17.  
  18. <select name= "combo_customer_code" OnChange="autoSubmit();"  >
  19. <option size =50 </option>
  20.  
  21. <?
  22. while($nt=mysql_fetch_array($result)){
  23. $code = $nt['customer_code'];
  24. echo '<option value="' .$nt['customer_code']. '">'. $nt['customer_code']. '</option>';
  25. }
  26. ?>
Dec 17 '09 #1
12 5469
zorgi
431 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. <option size =50 </option>
should probably be
Expand|Select|Wrap|Line Numbers
  1. <option size = "50"> 50 </option>
Also I don't see you closing <select></select>
Dec 17 '09 #2
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. <option size = "50"> 50 </option>
invalid, the size attribute belongs to the select element. valid attributes for <option> are: disabled, selected, label, value.
Dec 17 '09 #3
zorgi
431 Recognized Expert Contributor
ooops :)

ment it like this:
Expand|Select|Wrap|Line Numbers
  1. <option value = "50"> 50 </option>
  2.  
Apologies
Dec 17 '09 #4
manuitpro
13 New Member
I am not concerned about the size of the drop down, my concern is to make the drop down stick, </select> is there in my coding, i have put only part the code in the forum. Can u please comment on how to make my drop down sticky.
Dec 18 '09 #5
Dormilich
8,658 Recognized Expert Moderator Expert
what do you mean by “sticky”?
Dec 18 '09 #6
kovik
1,044 Recognized Expert Top Contributor
Sticky as in...?

Normally, sticky dropdowns refer to keeping the last selection as the current selection when the form is unsuccessfully submitted due to errors. Is this what you are after?

If so, make use of the "selected" attribute of the <option> elements. Note that in order to use it with XML/XHTML, W3C standards require that you make the value the name of the attribute.
Expand|Select|Wrap|Line Numbers
  1. <select>
  2. <option value="X">Not selected</option>
  3. <option value="X" selected>This is selected</option>
  4. <!-- XML: <option value="X" selected="selected">This is selected</option> -->
  5. <option value="X">Not selected</option>
  6. </select>
Dec 18 '09 #7
Dormilich
8,658 Recognized Expert Moderator Expert
Note that in order to use it, W3C standards require that you make the value the name of the attribute.
incorrect, the HTML specs explicitly state the attribute to be standalone.
Expand|Select|Wrap|Line Numbers
  1. <option value="X" selected>This is selected</option>
what you are talking about refers to the XHTML specs, where the attribute must be defined this way due to the XML specs. but since most people use XHTML as HTML (and not as XML), it doesn’t matter how you write it.
Dec 18 '09 #8
kovik
1,044 Recognized Expert Top Contributor
Note that in order to use it, XML standards require that you make the value the name of the attribute.
Fixed. :3
Dec 18 '09 #9
manuitpro
13 New Member
Thanks for ur replies... Let me put it again
I have two dynamic drop down's, first one pulls records from mysql and when user selects a option the second poulates values based on the user selected option in first one. Now what happens when user selects option in first drop down the pages refreshes and its selection reset to blank. I want to show the selected option in the first drop down when onchange happens. I want to preserve the selected after submitting the page(on change()). Please check my code above.
Dec 18 '09 #10

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

Similar topics

6
2456
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first drop down chosed. And I have a submite button to submit all these values to DB. First problem: I cant keep the value of the selected text in the...
2
11024
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on...
1
2896
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value...
3
6144
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box that appear when user clicks the drop-down arrow button. Because items in the Drop down list are a little long, user can't see the full thing when...
2
12603
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 select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list...
1
2493
by: pmelanso | last post by:
Hello, I have a drop down list which is dynatically loaded from a database and I have a second drop down list that is also dynatically loaded depending on what is selected in the first drop down box. This all works fine ... what isn't working is when I selected a different item in the first drop down list I want it to automatically reload the...
7
2426
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit the second drop down to just the related information. Explaining this is obviously challeging. So I'll try to draw a picture: (drop down 1)...
4
9280
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me if it works, and if it does not, tell me why it does not work. Thanks.
3
7341
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 document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is...
0
7977
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7730
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8026
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5252
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2163
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
984
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.