开发者

Jquery - Send only some value from a form

using the checkTL() function, i need to send to the server (for example) only the input valu开发者_运维问答e into div with class "sideon". So, in the example, i need to get (server side) only the value of inputside0 and inputside3. How is possible this? cheers


How about using AJAX?

<form method="POST" action="./index.php?general=example3" name="addtl">
    ...
</form>

and then:

$(function() {
    $('form[name=addtl]').submit(function() {
        var dataToPost = $(this).find('.sideon :input').serialize();
        $.post(this.action, dataToPost, function(result) {
            alert('success');    
        });
        return false;
    });
});

Of course putting input fields whose values shouldn't be submitted to the server into a form is doubtful. Maybe you should rethink the way you organize the forms.


two ways:

  1. make them into lots of seperate forms.
  2. do return false on the form submit in jquery and use $(".sideon").find('input').val(); to post an ajax query
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜