被选中后,在下拉列表中删除元素 [英] Remove element in drop down list after being selected

查看:284
本文介绍了被选中后,在下拉列表中删除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的数据库中的表存储车。然后在我的系统中,有一个下拉的汽车清单数据库(元素下拉:汽车A,汽车B,C号)。比方说,如果用户A选择租车B,汽车B就不会再供其他用户选择,当他们登录。我的问题是,如何使汽车无法再被选中?有没有办法,可以参考我的网页?被选中后如何删除在下拉列表中的元素?如果你不明白我的意思,随时问我。先谢谢了。

I have a table in my database which stores cars. Then in my system, there's a drop down list of the cars in the database (element in drop down : Car A,Car B,Car C ). Lets say if User A choose Car B, Car B will not longer available for the other user to choose when they login. My question is, how to make the car is not available to be selected anymore? Is there any page that I can refer? How to remove an element in the drop down list after being selected? If you don't understand what I mean, Feel free to ask me. Thanks in advance.

推荐答案

我会建议你创建另一个临时表在这里你可以保存 CarID 汽车code 的SessionID 当用户从下拉一辆车下来(您可以触发事件上选择一个项目)

I would suggest you create another temp table where you can save the CarID or CarCode along with sessionID When user selects a car from drop down (You can fire Event on selection an item )

在这种情况下保存carID&放大器; SESSIONID在临时表

on this event save the carID & SessionID in the Temp Table

表结构

 CarTempTable
    CarID xxx
    SessionID varchar(x)
    Date   datetime

一旦你有CarID&放大器;在此表中的SessionID,那么你可以查询你为其他用户主表与像

once you have CarID & SessionID in this table then you can query you main table for other user with a query like

SELECT CarID, CarName FROM Cars WHERE CarID NOT IN (SELECT CarID FROM CarTempTable WHERE SessionID <> "'+ SessionIDofUSER+'";

在上面的方法,你必须确保你清除会话结束用于特定会话的临时表项。

in the above approach you have to make sure you clear the temp table entries for the particular session on session end.

此方法应该为你工作。

编辑:如果是汽车租赁,然后这是好事,对你的表一个额外的列其中说,如果车用或不基于用户,如果图书的车。你可以用上面的临时表,因为我不知道你如何采取预约是通过支付或以其他方式

If it is car renting then it is good to have an extra column in you table which says if car is available or not based on if user books the car. you can use this with above temp table as i am not sure how you take booking is it by payment or by other means

这篇关于被选中后,在下拉列表中删除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆