Welcome to WebmasterWorld Guest from 54.166.54.215

Forum Moderators: open

radio buttons

Ajax inside of Javascript

   
7:58 pm on Feb 16, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I'm limited in my knowledge of Javascript and Ajax so bare with me.

I have a Javascript file that has a function in it. The function validates a form. At the end of that function is this:

  $.ajax({
type: "GET",
url: "thetargetedurl",
data: {
username: encodeURIComponent(username.value),
qq: encodeURIComponent(qq.value),
tel: encodeURIComponent(tel.value),
email: email.value,
product: question_1.value,
level: $("input[name='question_2']:checked").val(),
},

});


thetargetedurl has obviously been changed and the script works up to the last var being submitted: level. I can't get that to work.

Also. Once this submit is completed, I want the user to be taken to a thank you page (thankyou.php) but I can't get that to work either. I've tried using Javascript inside the function (window.location.href="thetarget"; and tried creating another function and then calling it at the end of this function. Still no go. Your help would be appreciated. TIA.
8:38 pm on Feb 16, 2012 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



What type of input element is 'question_2'? If it is a series of checkbox elements then you are going to get an array of values returned so you will need to choose the proper one from that array.
11:24 pm on Feb 16, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



question 2 is a group of radio buttons
2:33 pm on Feb 17, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



You have a comma at the end of the line containing level, and also on the line following it. If you remove those 2 commas, does it work?


$.ajax({
type: "GET",
url: "thetargetedurl",
data: {
username: encodeURIComponent(username.value),
qq: encodeURIComponent(qq.value),
tel: encodeURIComponent(tel.value),
email: email.value,
product: question_1.value,
level: $("input[name='question_2']:checked").val()
}
});
9:05 pm on Feb 17, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Thanks Fotiman, I'll check that out. I got the base code from online examples and they had the comma there which seemed odd but it worked for most of the variables. But I'll try it without the commas.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month