Saturday, 10 August 2013

how to pass java script value to php in codeigniter

how to pass java script value to php in codeigniter

i have a form where two fields are dynamically generated through java
script when a button is clicked.when the button is clicked each time,the
two text field will generate again and again.now i have got the count of
text field generated in a hidden field in JavaScript.How can i get the
value of hiddenfield in controller and insert the values of text fields in
database,by appending comma in data when the text box value is entered
each time.please help me.
my javascript is
<script>
var countbox=0;
var textbox1=0;
var textbox2=0;
function getField()
{
var newtextbox1="name1"+countbox;
var newtextbox2="name2"+countbox;
document.getElementById('renderDiv').innerHTML+='<br/><input type="text"
id="'+newtextbox1+'" name="'+newtextbox1+'" /><br/><input type="text"
id="'+newtextbox2+'" name="'+newtextbox2+'" />';
document.getElementById('renderDiv').innerHTML+='<br/><input type="hidden"
id="hiddentextField" name="hiddentextField" value="'+countbox+'" />';
countbox +=1;
}
</script>
my html code is
<input type="button" id="button1" onclick=getField();/>
<div id="renderDiv">
</div>
inside this div the two textfield is generated along with the hidden field

No comments:

Post a Comment