pass string from jquery to php
Can any 1 give me hints on how :
to send variables (array or string) from jquery to php...
I use jquery to copy/duplicate <select> box, I set to them different names and id's, and i need a way to pass the new name <select name=" ???"> to my index.php in order to do some calculations.
Is this bad way to do the job? Any ideas?
As far as i can see the best way would be to get <select name="???"> as soon as it's generated and that means using ajax (im not fammiliar with ajax nor js :( and i feel like idiot) .... Other way i think is to use aditional button that has function in same script to post the values (or one string value ready to be exploded in php)
This is how far i got :
<script type="text/javascript">
<!--//
var i=0;
var str=null;
var tablenames = new Array ();
var namevar=0;
$(document).ready(function(){
$("#add").click(function(){
namevar = (Math.floor(Math.random()*101));
var idvar = (Math.floor(Math.random()*101));
var newselect = $("#start").clone();
$(newselect).attr("name",namevar);
$(newselect).attr("id",idvar);
$(newselect).appendTo($("#destinations")).before("<br />");
tablenames[i]=namevar;
i=i+1;
});
});
function vrati(){
for (var i=0; i<tablenames.length; i++) {str = str + tablenames[i] + "&" }
$.post('index.php',{
retstring: str}
,function(data)
{
// alert(data);
})
}
document.getElementById("add").onclick = function(){
}
//-->
</script>