gpt4 book ai didi

javascript - 将变量传递到 Shadowbox 模态窗口?

转载 作者:行者123 更新时间:2023-12-02 19:49:02 24 4
gpt4 key购买 nike

我正在尝试向网站添加电子邮件服务。我弹出了一个带有 Shadowbox 的模式消息窗口(因为我已经在网站上将 Shadowbox 用于其他目的)。

问题是,我似乎无法将变量传递到打开的消息表单中。

我这样调用窗口

$(document).on("click","#mail",function(e){
e.preventDefault();
var thisParentClass = $(this).parent().attr("class");
alert (thisParentClass);
var thisIDpos = thisParentClass.indexOf("id-")+3;
var thisID = thisParentClass.substr(thisIDpos, 3);
alert(thisID);
Shadowbox.open({
content: '<form method="post" class="mailForm" action="#"><input type="hidden" name="memberID" value=thisID><p>Please be advised that the member may not be actively receiving mail.. or they might just not care at all. They have lives too you know.</p>Your E-mail:<input type="text" name="fromEmail" size="25"> <br>Your Name: <input type="text" name="fromName" size="25"> <br>Your Message: <br><textarea cols="50" rows="5" name="nMessage">Your Message Here...</textarea> <br><button type="submit" onclick="return false;" id="mailSubmit" value="Submit">Submit</button> ',
player: "html",
height: 350,
width: 350,
options: {modal:true}
});

我的所有警报都返回正确的值,但 [thisID] 没有进入我的消息表单。我只是不断获取“value =“thisID””的 HTML(请注意,无论我是否添加引号,引号都会包围我的变量)。有什么办法可以输入这个变量,或者我必须切换到另一个解决方案吗? (我希望我的窗口看起来都一样,所以如果我不能在这里使用 Shadowbox,我将不得不更改所有我的实现。B*tch。

我没有收到来自 Shadowbox 论坛的注册邮件,因此出于某种原因我可以在那里问这个问题,所以我想我应该在这里问。

想法?

最佳答案

替换这个:

<input type="hidden" name="memberID" value=thisID>

进入此:

<input type="hidden" name="memberID" value='+thisID+'>

您需要使用 + 符号将 thisID 的值连接到完整字符串中。

完整代码:

$(document).on("click","#mail",function(e){
e.preventDefault();
var thisParentClass = $(this).parent().attr("class");
alert (thisParentClass);
var thisIDpos = thisParentClass.indexOf("id-")+3;
var thisID = thisParentClass.substr(thisIDpos, 3);
alert(thisID);
Shadowbox.open({
content: '<form method="post" class="mailForm" action="#"><input type="hidden" name="memberID" value='+thisID+'><p>Please be advised that the member may not be actively receiving mail.. or they might just not care at all. They have lives too you know.</p>Your E-mail:<input type="text" name="fromEmail" size="25"> <br>Your Name: <input type="text" name="fromName" size="25"> <br>Your Message: <br><textarea cols="50" rows="5" name="nMessage">Your Message Here...</textarea> <br><button type="submit" onclick="return false;" id="mailSubmit" value="Submit">Submit</button> ',
player: "html",
height: 350,
width: 350,
options: {modal:true}
});

关于javascript - 将变量传递到 Shadowbox 模态窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9532674/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com