从下拉框中打开一个fancybox并直接将选定的值传递给它

问题描述 投票:2回答:2
<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在我看来是以前选择的值,我不知道为什么会发生这种情况...谢谢你

jquery drop-down-menu fancybox transfer
2个回答
0
投票

也许类似的问题? fancybox - show ajax content?

试试这个:http://jsfiddle.net/cR2SB/24/

<form><select id="mySelectboxsituation_found" >
<option value="">select</option>
  <option value="100">option 1</option>
  <option value="200">trigger</option>
  <option value="300">option 3</option>
</select> </form>

$(function(){
   $("#mySelectboxsituation_found").bind('change', function() {
       $.fancybox(
 'width': 800,
'height': 700,
 'type': 'iframe',
     href:'main_situation_found.php?incident_maincateid='+ $("#mySelectboxsituation_found").val()})});
  });

请记住,当您在javascript中绑定某些内容时,有时您可能会绑定当前值而不是事件时的值。


0
投票
<script language="JavaScript">
<!--
function openFB(url) {
 $.fancybox({
 'href' : url,
 'type' : 'iframe',
 'width': '900',
 'height': '700'
 });
}
-->
</script>
<form>
<select name="chooseItem" id="chooseItem" onchange="var goURL=document.getElementById('chooseItem').options[document.getElementById('chooseItem').selectedIndex].value;openFB(goURL);">
<option></option>
<option value="ref item 1 to open">Item 1</option>
<option value="ref item 2 to open">Item 2</option>
<option value="ref item 3 to open">Item 3</option>
</select>
</form>
© www.soinside.com 2019 - 2024. All rights reserved.