(javascript)onClick =" form.submit();不适用于IE&歌剧 [英] (javascript) onClick="form.submit(); doesn't work on IE & Opera

查看:145
本文介绍了(javascript)onClick =" form.submit();不适用于IE&歌剧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代码(见下文)。它在Firefox中完美运行:单击 __ JL_SAVE 按钮后保存提交的信息,并将用户保持在同一页面上。
但是在Internet Explorer&歌剧它只重定向到索引页(index.php),并不保存提交的信息。
我能做些什么来解决这个问题?



这是我的代码:

 < form action =index.phpid =mosFormmethod =postenctype =multipart / form-data> 

< fieldset>
< legend><?= __ JL_ABOUT_MYSELF?>< / legend>
< span class =aonclick =showHideLegend('about_myself_1')><?= __ JL_EDIT_BLOCK;?>< / span>
< div id =about_myself_descrstyle =display:block><?= __ JL_SELF_DESCR;?>< / div>
< div id =about_myself_1style =display:none><?php includehtml / about_myself_fill.php?>< / div>
< div id =about_myself_2><?php includehtml / about_myself_show.php?>< / div>
< / fieldset>

< fieldset>
< legend><?= __ JL_ABOUT_MYSELF?>< / legend>
< span class =aonclick =showHideLegend('type_1')> ($ typ_block){?>
<?php / *< input type =checkbox>< / =>< / span>
< id =jl_type_blockname =jl_type_block<?php if($ roon_type_block)echo'checked';?> /> * /?>
< input type =checkboxid = jl_type_blockname =jl_type_blockdisabled<?php echo'checked';?> />
< label for =jl_type_block><?= __ JL_ON_BLOCK?>< / label>
<?php} else {
echo __JL_OFF_BLOCK;
}?>

< div id =about_myself_descrstyle =display:block> ;<?= __ JL_SELF_DESCR;?>< / div>

< div id =type_1style =display:none>
<?php includehtml / type.php?>
< / div>
<?php if($ typ_block){?>
< div id =type_2>
<?php includehtml / type_show.php?>
< / div>
<?php}?>
< / fieldset>

< fieldset>
< legend><?= __ JL_INTEREST?>< / legend>
< span class =aonclick =showHideLegend('interest_1')><?= __ JL_EDIT_BLOCK;?>< / span>
<?php if($ interest_block){?>
< input type =checkboxid =jl_interest_blockname =jl_interest_blockdisabled<?php echo'checked';?> />
< label for =jl_interest_block><?= __ JL_ON_BLOCK?>< / label>
<?php} else
echo __JL_OFF_BLOCK;
?>
< div id =interest_descrstyle =display:block><?= __ JL_INTEREST_DESCR;?>< / div>
< div id =interest_1style =display:none>
<?php includehtml / interest.php?>
< / div>
<?php if($ interest_block){?>
< div id =interest_2>
<?php includehtml / interest_show.php?>
< / div>
<?php}?>
< / fieldset>


< input type =submitname =savevalue =__ JL_SAVEonClick =mosForm.submit(); />
< input type =hiddenname =optionvalue =com_joomlove/>
< input type =hiddenid =taskname =taskvalue =save_info/>
< / form>

完整源代码可在这里找到: http://narkoz.pastebin.com/f4f036f5

解决方案


  1. 如果您不改变表单的行为,为什么使用JavaScript来提交表单?,您已经在提交按钮中。

  2. 您应该尝试给出表单名称=mosForm,而不仅仅是id =mosForm,以便可以找到该事件处理程序的DOM引用。


I have a code (see it below). It works perfectly in Firefox: it saves submitted information after clicking __JL_SAVE button and keeps user on same page. But in Internet Explorer & Opera it only redirects to index page (index.php) and doesn't save submitted information. What can I do for solving this problem? Thanks.

Here is my code:

<form action="index.php" id="mosForm" method="post" enctype="multipart/form-data">

    <fieldset>
        <legend><?=__JL_ABOUT_MYSELF?></legend>
        <span class="a" onclick="showHideLegend('about_myself_1')"><?=__JL_EDIT_BLOCK;?></span>
        <div id="about_myself_descr" style="display: block"><?=__JL_SELF_DESCR;?></div>
        <div id="about_myself_1" style="display: none"><?php include "html/about_myself_fill.php"?></div>
        <div id="about_myself_2""><?php include "html/about_myself_show.php"?></div>
    </fieldset>

    <fieldset>
        <legend><?=__JL_ABOUT_MYSELF?></legend>
        <span class="a" onclick="showHideLegend('type_1')"><?=__JL_EDIT_BLOCK;?></span>
        <?php if ($typ_block) {?>
            <?php /* <input type="checkbox" id="jl_type_block" name="jl_type_block" <?php if ($roon_type_block) echo 'checked ';?> /> */ ?>
            <input type="checkbox" id="jl_type_block" name="jl_type_block" disabled <?php  echo 'checked ';?> />
            <label for="jl_type_block"><?=__JL_ON_BLOCK?></label>
        <?php } else {
            echo __JL_OFF_BLOCK;
        }?>

        <div id="about_myself_descr" style="display: block"><?=__JL_SELF_DESCR;?></div>

        <div id="type_1" style="display : none">
            <?php include "html/type.php"?>
        </div>
        <?php if ($typ_block) { ?>
            <div id="type_2">
                <?php include "html/type_show.php"?>
            </div>
        <?php } ?>
        </fieldset>

        <fieldset>
            <legend><?=__JL_INTEREST?></legend>
            <span class="a" onclick="showHideLegend('interest_1')"><?=__JL_EDIT_BLOCK;?></span>
            <?php if ($interest_block) {?>
                <input type="checkbox" id="jl_interest_block" name="jl_interest_block" disabled <?php echo 'checked ';?> />
                <label for="jl_interest_block"><?=__JL_ON_BLOCK?></label>
            <?php } else
                echo __JL_OFF_BLOCK;
            ?>
            <div id="interest_descr" style="display:block"><?=__JL_INTEREST_DESCR;?></div>
            <div id="interest_1" style="display:none">
                <?php include "html/interest.php"?>
            </div>
            <?php if ($interest_block) { ?>
                <div id="interest_2">
                <?php include "html/interest_show.php"?>
                </div>
            <?php } ?>
        </fieldset>


            <input type="submit" name="save" value="__JL_SAVE" onClick="mosForm.submit();" />
            <input type="hidden" name="option" value="com_joomlove" />
            <input type="hidden" id="task" name="task" value="save_info" />
            </form>

Full source available here: http://narkoz.pastebin.com/f4f036f5

解决方案

  1. If you're not changing the behavior of the form, why use JavaScript to submit the form?, you're already in a submit button.

  2. You should try giving the form name="mosForm", not just id="mosForm", so that the DOM reference from that event handler can be found.

这篇关于(javascript)onClick =&quot; form.submit();不适用于IE&amp;歌剧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆