A select drop-down list is created by reading the database + loop, but the specified value cannot be assigned through js. how can this problem be solved? (Not Enough)

Source: Internet
Author: User
A select drop-down list is created by reading the database + loop, but the specified value cannot be assigned through js. how can this problem be solved? (Scatter, not enough) I thought about it. this is not very relevant to js, but it is still a php issue. Problem background: there are some record lists on the left side of the page, and many empty boxes on the right side to fill in some information and save it. Click one of the records on the left to display the relevant information on the right. A select drop-down list is created by reading the database + loop, but the specified value cannot be assigned through js. how can this problem be solved? (Not Enough)
I thought, this is not very relevant to js, but it is still a php issue.

Problem background: there are some record lists on the left side of the page, and many empty boxes on the right side to fill in some information and save it. Click one of the records on the left to display the relevant information on the right. I have implemented all the above functions.
Problem: One of the many empty boxes on the right is the select drop-down list to select the car. My practice is to read carNum (integer type) from the database and use it as the option value in the select statement. The displayed value is the licenseNum (license plate number) of the vehicle in the database ), the above method is queried and implemented using php loop. However, when I use js to specify the select value for this id, the select statement does not respond at all. I replace this select statement with a definite select statement (that is, the php loop is removed, but the value and option name are directly set in htm). then js can specify the select value, the value is displayed.

But I want to cyclically set this select and js can specify this value (obviously, this can be dynamically displayed .)
How can this problem be solved? If the score is not enough, you can reply or send a private message to me.

Directly run the code:



QAZ123
WSX234
EDC345
TGB456



The following select statement is implemented in a loop:

 
$query = "select * from transport.truck order by carNum";
$data = getAll($query);
foreach($data as $each)
{
?>
 ">






Below is the js part I used:


    $(document).ready(function(){
        $(".LeftTask").click(function(){
       
            $(this).css("background","#A8A8A8");
            $(this).siblings().css("background","white");
            var orderID = $(this).find('input').val();
            $.ajax({
                type:"get",
                url:"main/ajax.php",

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.