一个简单的javascript问题

发布于 2024-12-09 20:44:39 字数 2377 浏览 1 评论 0原文

以下代码位于 WordPress 站点上。这是一个捐赠登陆页面,您可以从下拉列表中选择您的捐赠类别。选择类别后,会显示一个按钮,并允许用户继续捐赠(当前已禁用)。在 Safari、IE 和 Firefox 中工作得很好,没什么。任何人都可以提供任何帮助。提前致谢。要遵循的代码。

戴夫

    <p class="donate2">Donate Now</p>
    <table cellpadding="0" cellspacing="0" style="padding:0; width:890px; border:0 !important"><tr><td style="padding:0; border:0 !important;"><p>Our Mission is to give hope and a future back to children who are suffering through debilitating and life threatening illness. We are so very fortunate to have a wonderful team of volunteers and a base of generous donors which support these essential programs for children stricken with serious illness.</p>
    <p>Please use the following link to the right to make your payment via our secure checkout. All donations are 100% tax deductible. Payments for events may only be partially tax deductible. The Gambino Medical and Science Foundation is a 501(c) NonProfit, Tax Exempt Organization. (Federal Tax Exempt No. 13-3586460)</p></td>
    <td style="padding:0; border:0 !important">

    <script>
        function click(frm,value,button) {
            alert(value);
            frm.LinkId.value = value;
            if (value != "") {
                alert('Works');
                document.getElementById(button).style.display = "block"; 
            } else {
                alert('Works2');
                document.getElementById(button).style.display = "none"; 
            }
        }
    </script>

    <form style="float:right; margin-bottom: 100px; margin-left: 105px;" name="PrePage" id="Prepage" method ="post" action= "https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx">
    <select size="1" width="100" name="selectbox" id="selectbox" onchange="click(document.PrePage,document.PrePage.selectbox.options[selectedIndex].value,'button');" >
    <option selected value=""></option>
    <option value="4671dbc4-02ca-459d-8a46-c0783d38319e">General Donation</option>
    <option value="2">Dinner</option>
    </select>
    <input type="hidden" name="LinkId" id="LinkId" value="" /><input id="button" style="display:none;" type="image" src ="wp-content/themes/adsimple/i/donate_button.gif" /></form></td></tr></table>

The following code resides on a wordpress site. It is a donation landing page where you can select from a dropdown list, a category for your donation. Upon selecting a category a button shows and allows the user to continue with their donation(currently disabled). Works great in Safari, IE and Firefox, nothing. Can anyone provide any help. Thanks in advance. Code to follow.

Dave

    <p class="donate2">Donate Now</p>
    <table cellpadding="0" cellspacing="0" style="padding:0; width:890px; border:0 !important"><tr><td style="padding:0; border:0 !important;"><p>Our Mission is to give hope and a future back to children who are suffering through debilitating and life threatening illness. We are so very fortunate to have a wonderful team of volunteers and a base of generous donors which support these essential programs for children stricken with serious illness.</p>
    <p>Please use the following link to the right to make your payment via our secure checkout. All donations are 100% tax deductible. Payments for events may only be partially tax deductible. The Gambino Medical and Science Foundation is a 501(c) NonProfit, Tax Exempt Organization. (Federal Tax Exempt No. 13-3586460)</p></td>
    <td style="padding:0; border:0 !important">

    <script>
        function click(frm,value,button) {
            alert(value);
            frm.LinkId.value = value;
            if (value != "") {
                alert('Works');
                document.getElementById(button).style.display = "block"; 
            } else {
                alert('Works2');
                document.getElementById(button).style.display = "none"; 
            }
        }
    </script>

    <form style="float:right; margin-bottom: 100px; margin-left: 105px;" name="PrePage" id="Prepage" method ="post" action= "https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx">
    <select size="1" width="100" name="selectbox" id="selectbox" onchange="click(document.PrePage,document.PrePage.selectbox.options[selectedIndex].value,'button');" >
    <option selected value=""></option>
    <option value="4671dbc4-02ca-459d-8a46-c0783d38319e">General Donation</option>
    <option value="2">Dinner</option>
    </select>
    <input type="hidden" name="LinkId" id="LinkId" value="" /><input id="button" style="display:none;" type="image" src ="wp-content/themes/adsimple/i/donate_button.gif" /></form></td></tr></table>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

秋日私语 2024-12-16 20:44:39

将函数名称更改为 notClick 即可运行。

您的原始代码在 Chrome 中有效,但在 IE 和(某些版本的)Firefox 中无效的原因是

因此,

在 Chrome 中,这样的函数不存在,因此 click() 被解释为 window.click(),这是您定义的函数。

Change the function's name to notClick and it will work.

The reason why your original code works in Chrome, but not in IE and (some versions of) Firefox is that the <select> tag has a click() method in the latter two, but not in Chrome.

Therefore, the click() in <select onchange="click()"> gets interpreted as this.click(), which actually simulates a click on the select box.

In Chrome, such function does not exist, so click() gets interpreted as window.click(), which is the function you defined.

芸娘子的小脾气 2024-12-16 20:44:39

试试这个:

<select size="1" width="100" name="selectbox" id="selectbox" onchange="click(document.PrePage,document.PrePage.selectbox.options[this.selectedIndex].value,'button');" >
<option selected value=""></option>
<option value="4671dbc4-02ca-459d-8a46-c0783d38319e">General Donation</option>
<option value="2">Dinner</option>
</select>

try this:

<select size="1" width="100" name="selectbox" id="selectbox" onchange="click(document.PrePage,document.PrePage.selectbox.options[this.selectedIndex].value,'button');" >
<option selected value=""></option>
<option value="4671dbc4-02ca-459d-8a46-c0783d38319e">General Donation</option>
<option value="2">Dinner</option>
</select>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文