user1493339
user1493339

Reputation: 429

how to call? when i have same element name from 2 different forms within 1 page

here is the situation.

  1. i have 2 forms (formA, formB) in 1 page
  2. both forms having a input element with using same name='ClientID' (which dynamic generate base on database.
  3. so far i can different form with my jquery code below.

    $("form[name='FormA']").submit(function(){
        alert("FormA");
    });
    $("form[name='FormB']").submit(function(){
        alert("FormB");
    });
    
  4. so now under both forms hava a input element like

    <input type='text' name='ClientID' value=''>
    
  5. and now how i call FormA ClientID or FormB ClientID ? something like ...

    $("form[name='FormA']").submit(function(){
        $(this + ":input[name='ClientID']).val(); ???
    });
    

Upvotes: 1

Views: 67

Answers (2)

VisioN
VisioN

Reputation: 145458

For example, using find method:

$("form[name='FormA']").submit(function() {
    var value = $(this).find("input[name='ClientID']").val();
});

Upvotes: 0

Andrew Whitaker
Andrew Whitaker

Reputation: 126082

$("form[name='FormA']").submit(function(){
    $("input[name='ClientID']", this).val();
});

Upvotes: 1

Related Questions