最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery - Send only some value from a form - Stack Overflow

programmeradmin3浏览0评论

using the checkTL() function, i need to send to the server (for example) only the input value 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

using the checkTL() function, i need to send to the server (for example) only the input value 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

Share Improve this question asked Sep 19, 2010 at 16:24 markzzzmarkzzz 48.1k126 gold badges319 silver badges534 bronze badges 1
  • 1 Maybe a stupid question, but why are you requesting data in the form that you don't want? – David Thomas Commented Sep 19, 2010 at 16:28
Add a ment  | 

2 Answers 2

Reset to default 6

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)

  1. 暂无评论