For example, IF one click on ADD in order to add new radio button => FERRARI, Then is should be display 3 items and IF one click on DELETE in order to delete "BMW", result should be 2 items. I Hope i am clear to you.
Thanks for the code. I am begginer for JSON. I just would like to have exact flow for one demo for ADD or DELETE button. I need to know the actions behind the screen. I would like to have one complete file to understand the logic from which one can get the result. I have tried one example and i did like this.
Here is my code. I did what i know.
I would like to know NEXT Steps in order to get the expected results. Please let me know if you have ANY idea.
It is giving name for radio button all time "add". How one can enter the button value from user ? I need to do like at a time ONLY one button can be selected and then able to edit name/delete selected one. Any help would be great..!
var foo = document.getElementById("fooBar");
var radio1 = document.createElement("input");
var newL = document.createElement("label");
var newT = document.createTextNode("add");
newL.htmlFor = "id";
var br = document.createElement("br");
// php form
<!-- Add -->
<input type="hidden" name="Add" value="Add_btn" />
<input type="button" onclick="add()"/>
<!-- Delete -->
<input type="hidden" name="Delete" value="Delete_btn" />
<input type="button" value="Delete" onclick="delete()" />
It is user form. In my project, user can add/edit/delete radio button items on the form.
ANyway, you need to save it server-side (or to a cookie) for it to show on page refresh. You can either save it to SESSION, DB or cookie, or even XML or JSON. Your choice.
You also need to decide whether you want ajax to update after each addition and deletion. or a one-off save at the end. Loads of ways to do this.
OK, so research ajax saving (jQuery makes it easy - loads of tuorials out there). In a nutshell you can use $.post or $.ajax to pass data to a php file which updates the DB and then get the php to pass a msg back to js to say whether it was successful or not.