Hi People,
Got some issue with radio buttons...
I want to pass the form details WITHOUT PAGE REFRESH....
I have a textbox and 2 radio buttons with values Subscribe and Unsubscribe and a submit button.
The user has to enter his E-mail id in the given textbox and select either one radio button(Subscribe or Unsubscribe) and click on submit..
Front End code:
<head>
<script src="js/jquery-1.2.3.pack.js"></script>
<script src="js/tutorial.js"></script>
</head>
<div id="subscribecontainer">
<form action="" name="subscribeemail">
<input type="text" name="email" id="email" class="subscribeinp" value="Please Enter Your Email Address...." onclick="if(this.value=='Please Enter Your Email Address....'){this.value=''}" onblur="if(this.value==''){this.value='Please Enter Your Email Address....'}">
<label class="subscripterror" for="email" id="email_error">This field is required.</label>
<br/>
<br/>
<span class="radiobtn">
<input type="radio" name="subs" id="subs" value="Subscribed" checked="checked">Subscribe
<input type="radio" name="subs" id="unsubs" value="Unsubscribed">Unsubscribe
<input type="button" value="Submit" class="subscribebtn" id="submit_btn">
</span>
</form>
</div>
tutorial.js code contains:
$(function() {
$('.subscripterror').hide();
$('input.text-input').css({backgroundColor:"#FFFFFF"});
$('input.text-input').focus(function(){
$(this).css({backgroundColor:"#FFDDAA"});
});
$('input.text-input').blur(function(){
$(this).css({backgroundColor:"#FFFFFF"});
});
$(".subscribebtn").click(function() {
// validate and process form
// first hide any error messages
$('.subscripterror').hide();
var email = $("input#email").val();
if (email == "Please Enter Your Email Address....") {
$("label#email_error").show();
$("input#email").focus();
return false;
}
var sub = $("input#subs").val();
var unsub = $("input#unsubs").val();
var dataString = 'email='+ email + '&sub='+ subs + '&unsubs='+ unsubs;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "subsinsert.php",
data: dataString,
success: function() {
$('#subscribecontainer').html("<div id='subscribecontainer'></div>");
$('#subscribecontainer').html("<h2>Submitted!</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#subscribecontainer').append("<img id='checkmark' src='images/check.png' />");
});
}
});
return false;
});
});
runOnLoad(function(){
$("input#name").select().focus();
});
PROBLEM IS I WANT ONLY VALUE OF RADIO BUTTON TO BE PASSED... BUT ITS PASSING BOTH THE VALUES
Subscribed AND Unsubscribed
How to pass only one id...??