[英]set up form option as default in a drop down
I have created a driven database drop down menu on my website. 我在网站上创建了一个驱动数据库下拉菜单。 It sends the selected value by the user to the database to be checked and returns a specific item.
它将用户选择的值发送到要检查的数据库,并返回特定项目。
Everything works perfectly now but I'm trying to pre select the first value so that the user will have the first option as default and can add it to cart directly and they also can choose a different size. 现在一切都可以正常运行,但是我正在尝试预先选择第一个值,以便用户将第一个选项作为默认值,并且可以将其直接添加到购物车,他们还可以选择其他大小。 So far, I tried 'selected' inside the option in the drop down but it doesn't do anything but displays the value when the page loads.
到目前为止,我已尝试在下拉菜单中的“选择”内进行选择,但是它什么也没做,只是在页面加载时显示该值。
One last thing to mention, I'm using Ajax function to submit selected value and return result from the database. 最后要提到的是,我正在使用Ajax函数来提交选定的值并从数据库返回结果。
I can think of two ways for this. 我可以想到两种方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.