danny_woo Posted June 4, 2012 Share Posted June 4, 2012 Hi guys, So i got this problem with my form. It's a simple form for subscribing to a part of my website. Basically the form consists of 2 input fields, one is 'Name' and the other is 'Email Address' and the submit button is an image. The problem I have is at the bottom of my form I have two options: <label><input type="radio" name="subscription_status" value="radio" id="subscription_status_0")>Subscribe</label> (This selection is for users to Subscribe to the service) and next i have: <label><input type="radio" name="subscription_status" value="radio" id="subscription_status_1")>Subscribe</label> (This selection is for users to Unsubscribe to the service) What i want to do is if the user selects the "Subscribe" option and then his submit I want a message to popup saying something like "Thank you for subscribing". However if the user selects the "Unsubscribe" option and then hits submit I want a message to popup saying something like "Your subscription has been canceled". At the moment I can only work out how to get one message to popup when you hit the submit button. I need to understand how i can display the right message for the right selection. I hope someone can help us out on this one, I'm really new to java script so please go easy on me! Many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/263664-java-script-pop-up-message/ Share on other sites More sharing options...
noober Posted June 5, 2012 Share Posted June 5, 2012 You would check the value of the input selected, then pop-up your message. Make the value for each radio different. <label><input type="radio" name="subscription_status" value="0" id="subscription_status_0")>Subscribe</label> <label><input type="radio" name="subscription_status" value="1" id="subscription_status_1")>Subscribe</label> Something like this would work in jQuery (I haven't tested it): $('#yourFormId').submit(function() { var myValue = $('input[name="subscription_status"]:checked').val(); if(myValue == 0){ //popup message 0 here } else{ //popup message 1 here } return false; }); Quote Link to comment https://forums.phpfreaks.com/topic/263664-java-script-pop-up-message/#findComment-1351405 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.