douzhao6584 2013-09-29 11:55
浏览 23
已采纳

使用JavaScript发送ID

On my webpage I have this link:

<\a onclick="#" class="compose"></a>

By clicking the link, this script gets activated:

$(function(){
    $('.compose').click(function() { // Button which will activate our modal
        $('#popup_bestanden_edit_name').reveal({ // The item which will be opened with reveal 
            animation: 'fade',  // fade, fadeAndPop, none
            animationspeed: 600,                // how fast animtions are
            closeonbackgroundclick: true,   // if you click background will modal close?
            dismissmodalclass: 'close'  // the class of a button or element that will close an open modal
        });
        return false;
    });
});

The script above will make this DIV visible, wich is a popup:

<div id="popup_bestanden_edit_name">
<div id="popupheading">
    Naam wijzigen
</div>

<div id="popupcontent">
    <p><form action="" method="post" name="naamwijzigen"><input name="naam" type="text"></form></p>

    <a href="#" class="popupbutton green close"><img src="<?php echo $domein.'/images/confirm_popup/tick.png'; ?>">Ja, wijzigen</a>

    <a href="#" class="popupbutton red close"><img src="<?php echo $domein.'/images/confirm_popup/cross.png'; ?>">Nee, annuleren</a>
</div>

The popup that opens gives people the opportunity to edit a name of a document on the website. So when the link <\a onclick="#" class="compose"></a> is clicked, it has to send an id ($fetch_row['id']) to the popup, so I can use this in the further scripting.

Does anyone know how to do this?

  • 写回答

4条回答 默认 最新

  • droe9376 2013-09-29 12:39
    关注

    jQuery reveal plugin has many callback functions in which opened callback function that triggers 'after' the modal is opened. See docs at foundation.zurb.com

    echo "<a onclick='#' class='compose' id='".$fetch_row['id']."'></a>";
    
    $(function(){
        $('.compose').click(function() { 
    
            var id = $(this).attr('id'); //getting id from clicked anchor tag
    
            $('#popup_bestanden_edit_name').reveal({ 
                animation: 'fade',  
                animationspeed: 600,               
                closeonbackgroundclick: true,   
                dismissmodalclass: 'close',//missing comma (,) added
    
                opened: function(id) { 
                   $("#popup_bestanden_edit_name").append("<input type='hidden' name='myid' id='myid' value='"+id+"'>");
                }
    
            });
            return false;
        });
    });
    

    Your id will set in myid element in popup get this from here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度