从下拉框中打开一个 fancybox 并将所选值直接传递给它
<select name="mySelectboxsituation_found" id="mySelectboxsituation_found">
<option value="100">Firecall</option>
<option value="200">FireAlarm</option>
<option value="300">FireAlarm2</option>
<option value="400">FireAlarm4</option>
</select>
< a href="#" class="incidenttype" name="all" onClick="JavaScript:var dropdown=document.getElementById('mySelectboxsituation_found');this.href='main_situation_found.php?incident_maincateid='+dropdown.options[dropdown.selectedIndex].value;return true;"/>CLICK HERE < / a>
function cleanUp(){
var subsituation_found1 = $("#fancybox- frame").contents().find('input:radio[name=incident_subcate]:checked').val();
}
$(".incidenttype").fancybox({
'width' : 900,
'height' : 600,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'iframe',
'onCleanup': cleanUp
);
});
单击“单击此处”打开 fancybox 并传输下拉框中选择的值。
我想做的是,当我更改下拉框中的值时,打开精美的框...而不必单击“单击此处”链接...我知道可以使用类似 _this... 的内容。但我不确定并且正在寻找一些方向...
理想情况下是这样的事情...
<select name="mySelectboxsituation_found" id="mySelectboxsituation_found" onChange="JavaScript:var dropdown=document.getElementById('mySelectboxsituation_found');this.href='main_situation_found.php?incident_maincateid='+dropdown.options[dropdown.selectedIndex].value;return true;">
<option value="100">Firecall</option>
<option value="200">FireAlarm</option>
<option value="300">FireAlarm2</option>
<option value="400">FireAlarm4</option>
</select>
有人知道如何做到这一点...
我也尝试过...
function test_fan()
{ alert(document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value);
var dropval =document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value; return dropval;
}
$(document).ready(function(){
$("#autostart").fancybox({
'onStart':test_fan,
'width': 800,
'height': 700,
'type': 'iframe',
href:'main_situation_found.php?incident_maincateid='+document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value
});
<a href="#" id="autostart" style="display:none"></a>
<form><select id="mySelectboxsituation_found" onchange="$('#autostart').trigger('click');">
<option value="">select</option>
<option value="100">option 1</option>
<option value="200">trigger</option>
<option value="300">option 3</option>
<option value="400">option 4</option>
</select> </form>
发生的真正有趣的是....
在警报ID上确实获得了我选择的值,所以如果我
selected alert fancybox window
100 100 nothing shows up empty
200 200 100
300 300 200
400 400 300
在fancybox看来是之前选择的值,我不确定为什么会发生这种情况... 谢谢 安迪
<select name="mySelectboxsituation_found" id="mySelectboxsituation_found">
<option value="100">Firecall</option>
<option value="200">FireAlarm</option>
<option value="300">FireAlarm2</option>
<option value="400">FireAlarm4</option>
</select>
< a href="#" class="incidenttype" name="all" onClick="JavaScript:var dropdown=document.getElementById('mySelectboxsituation_found');this.href='main_situation_found.php?incident_maincateid='+dropdown.options[dropdown.selectedIndex].value;return true;"/>CLICK HERE < / a>
function cleanUp(){
var subsituation_found1 = $("#fancybox- frame").contents().find('input:radio[name=incident_subcate]:checked').val();
}
$(".incidenttype").fancybox({
'width' : 900,
'height' : 600,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'iframe',
'onCleanup': cleanUp
);
});
clicking on "CLICK HERE" opens the fancybox and transfers the value selected in the drop down box.
What I would like to do is open the fancy box when i change the value in the dropdown box...without having to click on the click here link.....i know it is posisble using something like _this....but i am not sure and am looking for some direction...
ideally some thing like this ...
<select name="mySelectboxsituation_found" id="mySelectboxsituation_found" onChange="JavaScript:var dropdown=document.getElementById('mySelectboxsituation_found');this.href='main_situation_found.php?incident_maincateid='+dropdown.options[dropdown.selectedIndex].value;return true;">
<option value="100">Firecall</option>
<option value="200">FireAlarm</option>
<option value="300">FireAlarm2</option>
<option value="400">FireAlarm4</option>
</select>
does any have an idea how to do it....
I have also tried...
function test_fan()
{ alert(document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value);
var dropval =document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value; return dropval;
}
$(document).ready(function(){
$("#autostart").fancybox({
'onStart':test_fan,
'width': 800,
'height': 700,
'type': 'iframe',
href:'main_situation_found.php?incident_maincateid='+document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value
});
<a href="#" id="autostart" style="display:none"></a>
<form><select id="mySelectboxsituation_found" onchange="$('#autostart').trigger('click');">
<option value="">select</option>
<option value="100">option 1</option>
<option value="200">trigger</option>
<option value="300">option 3</option>
<option value="400">option 4</option>
</select> </form>
the really funny that happens there is that ....
on the alert id do get the value i selected so if i
selected alert fancybox window
100 100 nothing shows up empty
200 200 100
300 300 200
400 400 300
the fancybox seems to me the the previously selected values and i am not sure why that is happening...
thanks
andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许类似的问题? fancybox - 显示ajax内容?
然后试试这个:http://jsfiddle.net/cR2SB/24/
请记住,当您在 javascript 中绑定某些内容时,有时您可能会绑定当前值而不是事件发生时的值。
Similar question maybe? fancybox - show ajax content?
Try this then: http://jsfiddle.net/cR2SB/24/
Keep in mind that when you bind something in javascript, sometimes you might be binding the current value instead of the value at the time of the event.