使用jQuery只贴前空变量 [英] Empty variables before post using jQuery ONLY

查看:69
本文介绍了使用jQuery只贴前空变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在特种部队检查这个问题, <一href="http://stackoverflow.com/questions/3223365/how-to-$p$pvent-form-element-from-sending-some-fields-we-dont-want">How从发送某些字段prevent表单元素,我们不想?

I have checked this question in SOF, How to prevent form element from sending some fields we don't want?

下面是我的code

的index.php

index.php

    <script type="text/javascript">
    $(formElement).submit(function() {
        ... how to do the jquery stuff.. 
        return true;
    });

    <?php
    $my_variable_with_value1 = 'abc';
    $my_variable_with_value2 = 'def';
    $another_one_variable = 'mango';
     ?>
    <form method="post" action="process.php">
    <input type="text" id="id1" name="name1" value="<?php echo $my_variable_with_value1 ?>"  />
    <input type="text" id="id2" name="name2" value="<?php echo $my_variable_with_value2 ?>"  />
    <input type="submit" value="Submit" />
    </form>

我需要做到以下几点 1.在提交页面使用jQuery我需要取消设置/空变量值仅 2.我要显示的index.php,而不是在下一页process.php变量

I need to do the following 1. Before the page is submitted i need to unset/empty the variable values using JQUERY ONLY 2. I have to show the variable in index.php and not in the next page process.php

在换句话说,我怎么能清空变量$ my_variable_with_value1和$ another_one_variable前网页递交使用jQuery

In other words, HOW CAN I EMPTY THE VARIABLES $my_variable_with_value1 AND $another_one_variable BEFORE PAGE SUBMIT USING JQUERY

谢谢, Kimz

推荐答案

使用code以下,您可以设置VAR1(ID)和var2(ID)为空值。

Using below code you can set value of var1 (ID) and var2 (ID) to blank.

<script type="text/javascript">
    $(formElement).submit(function() {
        $("#Var1").val("");
        $("#Var2").val("");
        return true;
    });

这篇关于使用jQuery只贴前空变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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