Can anyone point me in the right direction with this?
I have the following occuring:
<select> with option values to test what something is worth to a user - I'm varying the form processing based on the selection.
Everything functions fine, EXCEPT that in the <option value> code I'm using selected=selected on the $25.00 price (case)
What occurs is that everything functions great BUT if the user leaves the defaulted $25 and clicks the form submit button nothing happens, since the blur hasn't happened.
Can anyone point me in the direction of what I'd need to do to basically set the value onload for the selected amount to prevent this?
Here's the (hacky, yes for sure) code.
I have the following occuring:
<select> with option values to test what something is worth to a user - I'm varying the form processing based on the selection.
Everything functions fine, EXCEPT that in the <option value> code I'm using selected=selected on the $25.00 price (case)
What occurs is that everything functions great BUT if the user leaves the defaulted $25 and clicks the form submit button nothing happens, since the blur hasn't happened.
Can anyone point me in the direction of what I'd need to do to basically set the value onload for the selected amount to prevent this?
Here's the (hacky, yes for sure) code.
HTML:
//vary upsell based on selected price//
jQuery("#selectedprice").blur(function(){
var choice = $("#selectedprice option:selected").val();
switch(choice)
{
case "1.00": $("#submitimage").click(function () { // ATTACH CLICK EVENT TO MYBUTTON
$.post("noupsell.php", // PERFORM AJAX POST
$("#priceselect").serialize(), // WITH SERIALIZED DATA OF MYFORM
function(data){ // DATA NEXT SENT TO COLORBOX
$.fn.colorbox({
html: data,
open: true,
iframe: false, // NO FRAME, JUST DIV CONTAINER?
width: "750px",
height: "650px",
opacity: .50,
onClosed:function(){ location.reload(true); }
});
},
"html");
});
;
break;
case "5.00": $("#submitimage").click(function () { // ATTACH CLICK EVENT TO MYBUTTON
$.post("noupsell.php", // PERFORM AJAX POST
$("#priceselect").serialize(), // WITH SERIALIZED DATA OF MYFORM
function(data){ // DATA NEXT SENT TO COLORBOX
$.fn.colorbox({
html: data,
open: true,
iframe: false, // NO FRAME, JUST DIV CONTAINER?
width: "750px",
height: "650px",
opacity: .50,
onClosed:function(){ location.reload(true); }
});
},
"html");
});
;
break;
case "10.00": $("#submitimage").click(function () { // ATTACH CLICK EVENT TO MYBUTTON
$.post("upsell.php", // PERFORM AJAX POST
$("#priceselect").serialize(), // WITH SERIALIZED DATA OF MYFORM
function(data){ // DATA NEXT SENT TO COLORBOX
$.fn.colorbox({
html: data,
open: true,
iframe: false, // NO FRAME, JUST DIV CONTAINER?
width: "750px",
height: "650px",
opacity: .50,
onClosed:function(){ location.reload(true); }
});
},
"html");
});
;
break;
case "25.00": $("#submitimage").click(function () { // ATTACH CLICK EVENT TO MYBUTTON
$.post("upsell.php", // PERFORM AJAX POST
$("#priceselect").serialize(), // WITH SERIALIZED DATA OF MYFORM
function(data){ // DATA NEXT SENT TO COLORBOX
$.fn.colorbox({
html: data,
open: true,
iframe: false, // NO FRAME, JUST DIV CONTAINER?
width: "750px",
height: "650px",
opacity: .50,
onClosed:function(){ location.reload(true); }
});
},
"html");
});
;
break;
case "50.00": $("#submitimage").click(function () { // ATTACH CLICK EVENT TO MYBUTTON
$.post("upsell.php", // PERFORM AJAX POST
$("#priceselect").serialize(), // WITH SERIALIZED DATA OF MYFORM
function(data){ // DATA NEXT SENT TO COLORBOX
$.fn.colorbox({
html: data,
open: true,
iframe: false, // NO FRAME, JUST DIV CONTAINER?
width: "750px",
height: "650px",
opacity: .50,
onClosed:function(){ location.reload(true); }
});
},
"html");
});
;
break;
case "75.00": $("#submitimage").click(function () { // ATTACH CLICK EVENT TO MYBUTTON
$.post("upsell.php", // PERFORM AJAX POST
$("#priceselect").serialize(), // WITH SERIALIZED DATA OF MYFORM
function(data){ // DATA NEXT SENT TO COLORBOX
$.fn.colorbox({
html: data,
open: true,
iframe: false, // NO FRAME, JUST DIV CONTAINER?
width: "750px",
height: "650px",
opacity: .50,
onClosed:function(){ location.reload(true); }
});
},
"html");
});
;
break;
}
});