读书人

select的值如何传递

发布时间: 2013-12-30 14:16:08 作者: rapoo

select的值怎么传递
A页面
<select id="select2" multiple='multiple'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>

<input type="button" value="123" onclick="alert($('#select2').val())">
可以取到

B页面

<input type="button" value="123" onclick="alert($('#select2').val())">
就取不到了,我想取到,怎么做?
[解决办法]
那你就在你的B页面onclick时候window.opener.mytest()之后在你的A页面里边写一个mytest函数
function mytest(){
return $('#select2').val()
}
[解决办法]

引用:
Quote: 引用:

⊙⊙b汗,你的a和b要有关系才行啊。。什么关系你这2个页面,没有关系只能从a提交至到b去了

A页面选择 然后有个弹出框出来B页面


b可以用opener得到a的引用。

<input type="button" value="123" onclick="alert(opener.$('#select2').val())">

本地测试不要用webkit核心的,如chrome,未发布不能互相访问。chrome浏览器iframe parent.document为undefined

读书人网 >JavaScript

热点推荐