472,334 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

drop down sticky in php

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 5272
zorgi
431 Expert 256MB
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 Expert Mod 8TB
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 Expert 256MB
ooops :)

ment it like this:
Expand|Select|Wrap|Line Numbers
  1. <option value = "50"> 50 </option>
  2.  
Apologies
Dec 17 '09 #4
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 Expert Mod 8TB
what do you mean by “sticky”?
Dec 18 '09 #6
kovik
1,044 Expert 1GB
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 Expert Mod 8TB
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 Expert 1GB
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
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
kovik
1,044 Expert 1GB
Then I have already given you the solution that you are looking for. Use the "selected" attribute to select an <option>.
Dec 18 '09 #11
zorgi
431 Expert 256MB
This could help you with the logic:

http://www.dmcinsights.com/phorum/re...?9,15643,15661
Dec 18 '09 #12
Thank you all the experts...
After refering your comments finally I managed to make sticky dropdown.

I would personally thanks Zorgi for posting his Logic page
Dec 20 '09 #13

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

Similar topics

6
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...
2
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...
1
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...
3
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...
2
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...
1
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...
7
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...
4
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...
3
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.