通过URL参数选择语句选择
我试图通过使用 URL 来更改 HTML 表单的某些部分的内容。对于文本字段,我知道这就足够了,
http://
在表单上有多个选择大括号(下拉框) ;是否可以通过 url 选择一个 int 或 string 值?
似乎对此的文档很少(甚至人们试图做同样的事情)......
I'm attempting to alter the contents of certain parts of a HTML form through usage of the URL. For a text field, I'm aware that this will suffice,
http://<domain>?fieldname=ping&anotherfield=pong
On the form there are multiple select braces (drop down boxes); Is it possible to pick an int or string value through the url for this?
There seems to be little documentation on this (or even people trying to do the same)...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尚未指定要如何执行此操作,但我假设您要使用 JavaScript:
从 QueryString 获取值:
设置选择列表的选定值:
You haven't specified how you want to do this, but I'll assume that you want to use JavaScript:
To get a value from QueryString:
To set the selected value of the select list:
不,它不会(至少,不是以通用方式)。
对于文本字段,默认值由
value
属性指定。可能有一个服务器端脚本根据查询字符串数据填充它,但不一定有。同样,这需要设置一个属性(
上的
selected
),并且可以(再次)由服务器端脚本根据查询字符串进行设置数据。No, it won't (at least, not in a generic way).
For a text field, the default value is specified by the
value
attribute. There might be a server side script that populates it based on query string data, but there doesn't have to be.Again, this requires an attribute to be set (
selected
on<option>
), and that could (again) be set by a server side script based on the query string data.