如何查看是否选择了下拉列表,如果选择了,其值是什么。 Coldfusion/Javascript
简短的问题是:我在 Coldfusion / asp.net 中有一个网页,其中有许多下拉列表。我希望能够执行 if 语句来查看列表是否选择了某个项目,如果是,则获取该项目的值。
长版: 我有一个页面,其中有多个下拉列表,可以深入到该国家/地区的特定位置。当您打开页面时,只能选择一两个列表,其余列表均被隐藏。选择选项后,提交表单,提交表单后,新页面将旧数据加载到以前的列表中,并取消隐藏新列表等,直到检查了所有选项。它通过 url 存储这些变量,我正在编辑它以将其中一个列表拆分为两个列表。我无法向 url 添加更多变量。
我想要执行此操作的方法是添加一个隐藏的下拉列表,直到选择其上方的列表为止,然后使用该选择运行 sql 查询来获取数据以填充新列表。但是,我找不到一种简单的方法来检索上一个列表中的文本。
这是初始下拉列表的代码,一旦选择,我想从中填充一个新列表。
<select name="siteid" onChange="submitThis('site');">
<option value="">- SELECT ONE -</option>
<cfoutput query="getSites">
<option
value="#getSites.siteid#"
<cfif attributes.siteid eq getSites.siteid>SELECTED</cfif>
>#getSites.siteDetail#</option>
</cfoutput>
</select>
The short question is: I have a webpage in coldfusion / asp.net with many drop down lists. I want to be able to do an if statement to see if a list has an item selected, and if so grab the value of that item.
Long version:
I have a page that has multiple drop down lists to drill down to a specific location in the country. When you open the page only one or two lists are selectable, the rest are hidden. After an option is selected, the form is submitted and once the form is submitted, the new page loads the old data into the previous lists and unhides a new list, etc etc until all options have been checked. It is storing these variables by way of the url, I am editing it to split up one of the lists into two lists. I cannot add anymore variables to the url.
The way I wanted to do this, was add a drop down list that was hidden until the list above it was chosen, and then using that choice run a sql query to get the data to populate the new list. However, I could not find an easy way to retreive the text in the previous list.
Here is the code for the initial drop down, that once selected I want to populate a new list from.
<select name="siteid" onChange="submitThis('site');">
<option value="">- SELECT ONE -</option>
<cfoutput query="getSites">
<option
value="#getSites.siteid#"
<cfif attributes.siteid eq getSites.siteid>SELECTED</cfif>
>#getSites.siteDetail#</option>
</cfoutput>
</select>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个教程:
http ://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects
Try this tutorial:
http://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects