开发者

Autopopulate drop down from mysql

开发者 https://www.devze.com 2023-04-12 15:34 出处:网络
When trying to search for this specific thing I\'d like to do, I end up only finding how to create the drop down menu from a database, which I have already done. I\'m building a list to track complete

When trying to search for this specific thing I'd like to do, I end up only finding how to create the drop down menu from a database, which I have already done. I'm building a list to track completed tasks of a predefined number of people that are in their own table. The record will save the name of the person that completed the task What I'm looking for is as follows:

Employee Table:

--- (nothing selected)

Sara Johnson

John Doe

Mark O'Brien

Task Table:

Clean counters

Unlock doors

Turn on lights

So right now there is the task, then a drop down that puts the employees names in it. What I want is, if insert a record, then come back to the page, to automatically see if the task ha开发者_JAVA技巧s someone that has completed it and automatically select it, but leaves the possibility to be changed from the same drop down.

Right now, it will delete the current record with whatever the user puts in, so if they didn't know if someone turned on the lights, it will erase it and replace it with "---." This makes the user have to look up the record, see if anyone put anything in, then, basically recreate the record as it was, then add whatever changes they needed.

I hope that makes any kind of sense.


I have some trouble understanding your problem but what I assume you are looking for is a way to set the default selection of a drop down field. In HTML you can do that by adding the attribute selected="selected" to the <option> tag. It would look like this:

<select name="foo" size="1">
    <option value="1">Value 1</option>
    <option value="2" selected="selected">Value 2</option>
</select>

If that is not what you meant, please explain further. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号