i have a code for dynamically created textbox,radiobutton,checkbox..and my question is How can i save the dynamically created textbox checkbox ,radiobutton into MYSQL Database .
<div class="maindiv">
<div id="header"></div>
<div class="menu">
<button id="namebutton"><img src="images/name-img.png">Name</button>
<button id="emailbutton"><img src="images/email.png">Email</button>
<button id="addressbutton"><img src="images/contact-img.png">Address</button>
<button id="checkboxbutton"><img src="images/check-img.png">CheckBox</button>
<button id="radioaddbutton"><img src="images/radio-img.png">Radio</button>
<button id="reset">Reset</button>
</div>
<div class="InputsWrapper1">
<div id="yourhead">
<div id="your">
<h2 id="yourtitle">Your Form Title<img src="images/edit-form.png"></h2>
<h4 id="justclickid">Just Click on Fields on left to start building your form. It's fast, easy & fun.</h4>
</div>
</div>
<div id="InputsWrapper"></div>
</div>
</div>
here is the link for my code link ....and its working fine for me but not working in jsfiddle above link
I would suggest serializing your form's content into a string and simply storing that string in a field called something like form_data
.
To do this, you would need to ensure that all of your elements that you want to save are nested within a <form>
tag. Once you have that you can call the .serialize()
function on your form element.
From the documentation:
The
.serialize()
method creates a text string in standard URL-encoded notation. It can act on a jQuery object that has selected individual form controls, such as<input>
,<textarea>
, and<select>
:$( "input, textarea, select" ).serialize()
;It is typically easier, however, to select the
<form>
itself for serialization
var form_string = $("#my_dynamic_form").serialize();
This serialization will give you a string in the following format:
single=Single&multiple=Multiple&multiple=Multiple3&check=check2&radio=radio2
As you can see, this string can be easily saved into the database in a single column. To decode the values in PHP (for example), you can use the parse_url()
function:
$form_string = "single=Single&multiple=Multiple...";
parse_str($form_string, $form_data);
The $form_data
will now contain the following data:
Array (
[single] => "Single"
[multiple] => "Multiple"
...
)