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

发布于 2024-10-13 12:00:50 字数 3357 浏览 2 评论 0原文

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三岁铭 2024-10-20 12:00:50

也许类似的问题? fancybox - 显示ajax内容?

然后试试这个: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 中绑定某些内容时,有时您可能会绑定当前值而不是事件发生时的值。

Similar question maybe? fancybox - show ajax content?

Try this then: 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()})});
  });

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.

以酷 2024-10-20 12:00:50
<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>
<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文