Select Boxes and Conditional Statements

Discussion in 'Javascript' started by Gregc., Aug 28, 2006.

  1. Gregc.

    Gregc. Guest

    Hi Again

    I am trying to get this conditionals statement to work. Basically, if
    the op clicks 1-5, then it prints the qty in the qty box, and the name
    of the pizza in the pizza box. If the op clicks on 0, then the order
    for that product is removed. If clicks on the changes the order ie
    qty, then the new qty appears. The orders appear one after another.
    For some reason I can select on the qty and that qty won't appear int
    the orderqty select box. Here is the code:




    <html>
    <head>
    <script type="text/javascript">
    function updateOrder(obj){
    var codesInlist= obj.options.length;
    var type = obj.name;
    var pizza= new Array("Supreme", 12);
    var pizza2 = new Array("Italian",12);
    var w=obj.selectedIndex;
    var selected_text = obj.options[w].text;
    var qty1=document.getElementById("orderQty");
    var piz1=document.getElementById("PizzaType")
    var clearqty1 =qty1.options.length = 0;
    var clearName1 = piz1.options.length=0;

    //Tests to see if the pizza type is supreme
    if(type==pizza[0]){
    if(w == 0){
    clearqty1;
    clearName1;}
    else{
    // adds the number selected to the select box
    qty1.options[qty1.options.length] = new Option(selected_text);
    piz1.options[piz1.options.length]=new Option(pizza[0])
    }
    }
    //Tests to see if the pizza type is Italian
    if(type==pizza2[0]){
    if(w == 0){
    clearqty1;
    clearName1;
    }
    else{
    // adds the number selected to the select box
    qty1.options[qty1.options.length] = new Option(selected_text);
    piz1.options[piz1.options.length]=new Option(pizza2[0])

    }
    }
    }

    </script>
    </head>
    </script>
    </head>
    <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"
    style="text-align:center">
    <form name="form1" method="post" action="" onsubmit="">
    <select name="Supreme" id="Supreme" onchange="updateOrder(this);">
    <option>0</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select>
    <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"
    style="text-align:center">
    <form name="form1" method="post" action="" onsubmit="">
    <select name="Italian" id="Italian" onchange="updateOrder(this);">
    <option>0</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select>
    <td bgcolor="#FFE9BB" class="borderBR"><select name="Type of Pizza"
    size="10" id="PizzaType">

    <option>Pizza Ordered</option>

    </select> </td>


    <td bgcolor="#FFE9BB" class="borderBR"><select name="orderQty" size="4"
    multiple="multiple" id="orderQty">
    </select>

    </body>
    </html>

    Greg
    Gregc., Aug 28, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil Zanella
    Replies:
    8
    Views:
    1,180
    mfmehdi
    Oct 20, 2006
  2. Porthos
    Replies:
    3
    Views:
    482
    Joris Gillis
    Feb 7, 2005
  3. Stefan Mueller
    Replies:
    5
    Views:
    12,374
    jamesxa
    Jun 16, 2009
  4. John Crichton
    Replies:
    6
    Views:
    259
    John Crichton
    Jul 12, 2010
  5. Select boxes to select sets

    , Sep 14, 2005, in forum: Javascript
    Replies:
    5
    Views:
    100
    Dr John Stockton
    Sep 17, 2005
Loading...

Share This Page