I am using this code to populate a drop down list from mysql database.
I need to pass id and name through this code.but the problem is the value is lost when the page gets refreshed.and it works fine if i pass only name through it.
my code is as follows:
ok.more precisely, i am using this form in such a way that,when client name is selected, it will submit the form and will show the quotation numbers related to that client.but when the value is submitted,it shows the quotations, but dosent show the client name.is there any solution for this??
Yes there is. To get to the solution, more needs to be known about the problem.
What is the bad HTML code. You can see the rendered HTML code by right-clicking on the page and selecting “View page source”, or something equivalent.
I suspect that the problem is that you are placing the name as an attribute of the html element instead of as the content part of the element itself, but the only way to find out for sure is to confirm that suspicion against the actual HTML code itself.
By knowing what’s going bad, we can adjust the PHP script so that it created good code. Anything else and we’re just making blind stabs in the dark.
Yes it is not showing any value in “selected” attribute in page source.probably because client_id is not posted.
please have a look at the example:http://believecreation.org/test/test.php.
when values are selected from both of the drop downs,the values are lost.:(:(
If you don’t want to change anything about the form values, or the way the form values are interpreted, then you need an in-between step where you use the POSTed number to retrieve the name from the database.
You can use that POSTed name id to create a new result row that that has 1 where the name matches the id, or 0 where it doesn’t.