使用jQuery只贴前空变量变量、jQuery、只贴前空

2023-09-10 19:05:55 作者:套路撩人

我在特种部队检查这个问题, 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;
    });