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(), - <script language="JavaScript">
-
-
function autoSubmit()
-
{
-
var formObject = document.forms['theForm'];
-
formObject.submit();
-
}
-
-
</script>
-
-
<form name="theForm" method="post">
-
-
<?
-
$code_query = "select customer_code from customer";
-
$result = mysql_query($code_query);
-
?>
-
-
<select name= "combo_customer_code" OnChange="autoSubmit();" >
-
<option size =50 </option>
-
-
<?
-
while($nt=mysql_fetch_array($result)){
-
$code = $nt['customer_code'];
-
echo '<option value="' .$nt['customer_code']. '">'. $nt['customer_code']. '</option>';
-
}
-
?>
12 5272 - <option size =50 </option>
should probably be - <option size = "50"> 50 </option>
Also I don't see you closing <select></select>
- <option size = "50"> 50 </option>
invalid, the size attribute belongs to the select element. valid attributes for <option> are: disabled, selected, label, value.
ooops :)
ment it like this: -
<option value = "50"> 50 </option>
-
Apologies
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.
what do you mean by “sticky”?
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. - <select>
-
<option value="X">Not selected</option>
-
<option value="X" selected>This is selected</option>
-
<!-- XML: <option value="X" selected="selected">This is selected</option> -->
-
<option value="X">Not selected</option>
-
</select>
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. - <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.
Note that in order to use it, XML standards require that you make the value the name of the attribute.
Fixed. :3
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.
Then I have already given you the solution that you are looking for. Use the "selected" attribute to select an <option>.
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
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.
...
|
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...
|
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...
|
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...
| |