forum

Home / DeveloperSection / Forums / How to get element name of value?

How to get element name of value?

Anonymous User188004-Oct-2014
need to get all text of value, then use json to send the value to insert all of price to the database, but i had the problem, i can't get the text of all value where input text name='price'. here this is HTML code:
here is Html code:
<inputtype='text'id='price1'name='price[]'/>
 
<inputtype='text'id='price2'name='price[]'/>
 
<buttontype='button'id='btn'/>

JQuery code:

 

<script>
    $('#btn').click(function (e) {
        var myprice = [];
        myprice = $("*[name='price']").val();
        $.post(
            "index.php",
            {
                type: "insert",
                price: myprice,
            }
        ).done(function (data) {
            console.log(data);
        })
    });
</script>


Updated on 04-Oct-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By