Hello All,
I have the following jQuery script that I would like to post to my mysql database with php. How would I go about getting this information to post to the database? Here is what I have so far.
Thank you in advance.
<script>
$(document).ready(function () {
//we want to intialze the values
values = {};
values['vehicle'] = "car";
values['gender'] = "male";
values['age'] = "25";
values['position'] = "manager";
//we need to handle the image clicks
$("#car, #bus, #train, #boat, #plane, #man, #woman, #25, #35, #45, #55, #manager, #director, #president, #CXO").click(function (event) {
event.preventDefault();
//we want to know what row we are dealing with
var imageclass = $(this).attr('class');
//we need all of the other images in the row turned to not selected
$("." + imageclass).each(function() {
if ($(this).id != event.target.id)
{
var src = $(this).attr('src');
if (src.indexOf("2") >= 0)
{
$(this).attr('src', src.replace("2.png", ".png"));
}
}
});
setImageAsSelected(event.target.id);
});
function setImageAsSelected(id) {
var current = $("#" + id).attr('src');
var next;
if (current.indexOf("2") < 0) {
next = current.replace(".png", "2.png");
}
$("#" + id).attr('src', next);
values[$("#" + id).attr('class')] = id;
}
//we need to handle the go click
$("#go").click(function () {
var sql = "INSERT INTO TABLE (Vehicle, Gender, Age, Positon) VALUES ('" + values['vehicle'] + "', '" + values['gender'] + "', '" + values['age'] + "','" + values['position'] + "');";
alert(sql);
});
});
</script>