I want to be able to send all the selected values from a listbox as a hidden field using JQuery. I was able to send/retrieve a single value on form submission.
如果有人可以分享一些代码片段,那将有所帮助。
提前感谢!
I want to be able to send all the selected values from a listbox as a hidden field using JQuery. I was able to send/retrieve a single value on form submission.
如果有人可以分享一些代码片段,那将有所帮助。
提前感谢!
嗯,你到底在要求什么还不太清楚。HTML中没有“多选下拉列表”。要进行多选,您需要指定
<select id="foobar" multiple>
这将创建一个列表框
,您可以在其中选择多个元素。使命感
var sel = $( #foobar ).val();
将返回所选项目的数组
。
编辑
要从每个选项中获取文本,请使用.map()
或jQuery.map(()
。示例:
var sel = $( #foobar ).children( option:selected ).map(function(i,e){
return e.innerText;
}).get();
这将创建一个数组,其中包含所有选定条目的文本。
绝对没有必要这样做。 您显然使用request.getPara公尺(
。 而不是request.getParacales(
>,并想知道为什么只归还第一种价值。
只需相应地修复servlet代码:
String[] selectedItems = request.getParameterValues("dropdownname");
不需要丑陋的JS/jQuery黑客将它们全部作为单个参数发送。在未来的问题中,试着问如何解决问题,而不是如何实现一个解决方案,毕竟这个解决方案本身可能不是正确的解决方案。
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...
<form><input type="file" name="first" onchange="jsFunction(2);"> <input type="file" name="second" onchange="jsFunction(3);"</form> Possible to pass just numbers to the js ...
So I ve got a menu with a hover/selected state and it loads fine in IE6/IE7. However when I scroll down the page and put the element outside of the viewport and then back in I get a broken image! I ...
I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!