Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting value of second input located inside the form. javascript jquery

I have this html form

echo "<form name='delete_article_form".$row['id']."' action='sources/public/article_processor.php' method='POST' >";
echo "<input name='processor_switcher' id='processor_switcher' type='hidden' value='delete_article'><input name='article_id' id='article_id' type='hidden' value='".$row['id']."'><a class='delete_button' href='#'>".$s_delete[$lid]."</a>";
echo "</form>";

Now here is jquery code

$('.delete_button').live('click',function(){
article_id = ???????
        alert(article_id);
    });

What should I do to get the value from input named "article_id"? Problem is that I have several such forms on my page so I must use THIS statement. input=$('input',this).val(); will not help cause there are 2 inputs.

Any Ideas?

like image 869
David Avatar asked Dec 13 '22 10:12

David


1 Answers

Try

var article_id = $(this).closest('form').find('input[name="article_id"]').val();

If you want the 'second' input, then you can do this

var article_id = $(this).closest('form').find('input').eq(1).val();
like image 163
Dogbert Avatar answered May 10 '23 05:05

Dogbert