homepage Welcome to WebmasterWorld Guest from 54.227.34.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
radio buttons
Ajax inside of Javascript
lorax

WebmasterWorld Administrator lorax us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4418466 posted 7:58 pm on Feb 16, 2012 (gmt 0)

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.

 

coopster

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



 
Msg#: 4418466 posted 8:38 pm on Feb 16, 2012 (gmt 0)

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.

lorax

WebmasterWorld Administrator lorax us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4418466 posted 11:24 pm on Feb 16, 2012 (gmt 0)

question 2 is a group of radio buttons

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4418466 posted 2:33 pm on Feb 17, 2012 (gmt 0)

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()
}
});

lorax

WebmasterWorld Administrator lorax us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4418466 posted 9:05 pm on Feb 17, 2012 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved