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