Skip to Content
author's profile photo Former Member
Former Member

check Delivery To (shipCond) selected key value when Ordering

Hi Experts,

I have a requirement to check Delivery To (shipCond) selected key value (not description) when hit Order, if selected key value is not "01" or "03", give certain message. below is my code lines added in function send_confirm()in orderTools.js, which give error "Object expected", I know 1st line is not right but don't know how to correct it.

String sc = document.forms['order_positions'].shipCond.value.toString();

if (!sc.equals("01") && !sc.equals("03")) {

................................ }

Any advise on how to correct it?

Thanks, Jin

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 02, 2009 at 02:56 AM

    Hi Jin,

    Try below.

    First get the reference of Select Box for Delivery to

    var x=document.getElementById("shipCond");
    

    Once you have reference of Select Box try to get value (Not Text) of selected option.

    var val = x.options[x.selectedIndex].value;
    

    Once you have value in variable val you can use it in IF condition

    if ((val != "01") && (val !="03")) {
       .......
    } else {
     ............
    }
    

    All together.

    var x=document.getElementById("shipCond");
    var val = x.options[x.selectedIndex].value;
    if ((val != "01") && (val !="03")) {
       .......
    } else {
     ............
    }
    

    All above code is in Javascript.

    Put this all in function send_confirm().

    Let me know if you have any question or you get any error.

    eCommerce Developer

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.