Handle onBlur event in FireFox

Discussion in 'JavaScript' started by greatlogix, Apr 30, 2007.

  1. #1
    Gurus. I am using onblur event to update price on a form. Script is working well in IE but I think FF does not support onBlur. How can I call update_price function onBlur event of FF.
     
    greatlogix, Apr 30, 2007 IP
  2. sky22

    sky22 Guest

    Messages:
    59
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    FF does support onBlur, well 2.0.0.3 does anyway I've used it. It might be something else in your code that's stopping it working in firefox. If you post the bits that aren't working in FF someone might be able to help you.

    Sky22
     
    sky22, Apr 30, 2007 IP
  3. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #3
    For which element is the onblur event ? Maybe a select ?
    If yes, try with onchange="your_function_selected(this.selectedIndex)"
     
    ajsa52, Apr 30, 2007 IP
  4. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #4
    This is the function call
    <input name='cq1' type='text' id='cq1' size='5' maxlength='5' onblur="update_status(); show_price(); ">

    and following is the long show_price function

    function show_price(){
    for (var i=0; i < document.frm1.stype.length; i++){
    if (document.frm1.stype.checked){
    var rad_val = document.frm1.stype.value;
    }
    }
    a = rad_val;
    flag_flat = flag_sheet = flag_fitted = 0
    sheetcount = 0;
    if(document.frm1.ptypes[0].checked){
    fitted = document.frm1.ptypes[0].value;
    }
    else fitted = 0;

    if(document.frm1.ptypes[1].checked){
    flat = document.frm1.ptypes[1].value;
    }
    else flat = 0;

    if(document.frm1.ptypes[2].checked){
    set = document.frm1.ptypes[2].value;
    }
    else set = 0;

    //alert(fitted)
    //else
    qty = 0;
    if(document.frm1.cq1.value != ""){
    if(isNumber("frm1","cq1")==false){
    alert("Please enter numeric quantity!");
    document.frm1.cq1.focus();
    return false;
    }

    qty = qty + parseFloat(document.frm1.cq1.value)
    }
    if(document.frm1.cq2.value != ""){
    if(isNumber("frm1","cq2")==false){
    alert("Please enter numeric quantity!");
    document.frm1.cq2.focus();
    return false;
    }
    qty = qty + parseFloat(document.frm1.cq2.value)
    }
    if(document.frm1.cq3.value != ""){
    if(isNumber("frm1","cq3")==false){
    alert("Please enter numeric quantity!");
    document.frm1.cq3.focus();
    return false;
    }
    qty = qty + parseFloat(document.frm1.cq3.value)
    }
    //alert(qty)


    flats = parseFloat(flat) * qty;
    fitteds = parseFloat(fitted) * qty;
    sheets = parseFloat(set) * qty;
    stypes = parseFloat(a) * qty;
    gtotal = flats + fitteds + sheets + stypes;
    ggtotal = gtotal.toFixed(2)
    //gtotal = total*qty
    document.getElementById('price').innerHTML = '$'+ggtotal;
    document.frm1.pprice.value = gtotal;
    if(document.frm1.pprice.value > 1)
    document.all['cart'].innerHTML= '<input type="submit" name="PlaceOrder" value="Add to Cart" style="font-size: 10pt; font-family: sans-serif; font-style: normal;" >';
    else
    document.all['cart'].innerHTML = '<input type="submit" name="PlaceOrder" value="Add to Cart" style="font-size: 10pt; font-family: sans-serif; font-style: normal;" disabled="disabled">';
    }
     
    greatlogix, Apr 30, 2007 IP
  5. sky22

    sky22 Guest

    Messages:
    59
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I'm not 100% sure but I think it might be you need to use document.getElementById("frm1") instead of document.frm1 but I'm not sure. Someone on here will know though :)

    Sky22
     
    sky22, Apr 30, 2007 IP
  6. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #6
    Suggestions:
    - Use event onChange instead of onBlur
    - Add name and id attributes to your checkboxes, so you can:
    - Use document.getElementById() function instead of getdocument.all
    Hope this help.
     
    ajsa52, Apr 30, 2007 IP
  7. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #7
    Thanks ajsa52 and Sky22 I will try it. I hope this will work
     
    greatlogix, Apr 30, 2007 IP