0

I have form(<input type="button">) in my html file, so for every input button I need to store those values in my json file/object after clicking Submit button, either using jquery or javascript or angularjs ? I have created Fiddle, but I am not sure where I am doing wrong ? Please help me this regard and thanks in advance.

1 Answer 1

2

Not getting your exact requirement but I think you can do some thing like this:

(function(){

var buttonValue = {};
   


$("#submit").click(function(){
 $("input[type=button]").each(function($i){
 var name =$(this).attr('name')     
 buttonValue[name]=$(this).val();
});
});

$("#seeData").click(function(){
 console.log(buttonValue);
});

}())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type='button' value='button1' class='button' name='firstButton'/>
<input type='button' value='button2' class='button' name='secondButton'/>
<input type='button' value='button3' class='button' name='thirdButton'/>

<input type='submit' value='submit' id='submit'>
<button id='seeData'>See Data In Console</button>

Sign up to request clarification or add additional context in comments.

9 Comments

Hi Anand Singh, Thanks for your reply, my requirement is that I need to store my input types(of button) into json file/object.
WC so you want to save all value of input type button in json/file when click to submit right?? wait i will edit.
check edited click submit and then click See Data button and ckech in console.
exact url is not available at client side for security purpose but you can get name by $('input[type=file]')
Thanks you for your valuable support Anand Singh !!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.