This topic is locked
[SOLVED]

 function on javascript onLoadEvents page

5/10/2012 1:50:37 PM
PHPRunner General questions
S
stiven author

Hello all,
I made a button on the edit page its called "Order Flowers", this button is calling a function check_fields(); I wrote this function on the JS onLoad Events page, function is below. the problem is that I am getting an error "check_fields is not defined" I already check and it is include on the js events page. looking through the source of the page it seems like the events page is include at the bottom of the page is this correct? if it is then is there a way to fix this? so that i won't get undefined.. thanks.



function check_fields(){
if(floresm.getValue() == "")

{ alert("Flowers Message Can Not Be Blank");

floresm.style.backgroundColor='red';

floresm.focus();

return false;}else{floresm.style.backgroundColor='white';}



if(florest.getValue() == "")

{ alert("Flowers Type Can Not Be Blank");

florest.style.backgroundColor='red';

flroest.focus();

return false;}else{florest.style.backgroundColor='white';}



if(florescom.getValue() =="")

{ alert("Company Can Not Be Blank");

florescom.style.backgroundColor='red';

florescom.focus();

return false;}else{florescom.style.backgroundColor='white';}
if(vdate == "" || vdate == "0000-00-00")

{ alert("Please wait until viewing is reserved");

return false;}
if(florest.getValue() != '' && floresm.getValue() != '' && florescom.getValue() != '' && vdate != '0000-00-00'){
$("input[type='button'][name='send_email']").click(function(e){

$.ajax({

type: "GET",

url: "include/orders.php",

data: "case_id="+$(this).attr('case_id')+"&order_type="+$(this).attr('order_type')+"&company="+$(this).attr('company'),

success: function(msg){

alert("Order Sent.");

}



})

$(this).attr("disabled","disabeld");

$(this).attr("value","Order Sent");

});
}
}
C
cgphp 5/11/2012

Post the code of the button.

S
stiven author 5/11/2012



Post the code of the button.


i fixed it i put the validation inside other function that is called when the button is pressed



$("input[type='button'][name='send_email']").click(function(e){



if(florest.getValue() == "")

{ alert("Flowers Type Can Not Be Blank");

florest.setFocus();

return false;}
if(floresm.getValue() == "")

{ alert("Flowers Message Can Not Be Blank");

floresm.setFocus();

return false;}



if(florescom.getValue() == "")

{ alert("Company Can Not Be Blank");

florescom.setFocus();

return false;}
if(vdate == "" || vdate == "0000-00-00")

{ alert("Please wait until viewing is reserved");

return false;}
if(flores.getValue() == 0)

{ alert("Please save the info before making the order");

return false;}



if(florest.getValue() != '' && floresm.getValue() != '' && florescom.getValue() != '0' && vdate != '0000-00-00')
$.ajax({

type: "GET",

url: "include/orders.php",

data: "case_id="+$(this).attr('case_id')+"&order_type="+$(this).attr('order_type')+"&company="+$(this).attr('company'),

success: function(msg){

alert("Order Sent."); }



})

$(this).attr("disabled","disabeld");

$(this).attr("value","Order Sent");

});