Array and If

Array and If

Hi erverybody,

I have a small form, where the user can select how his route to the destination should be (car or train).

  1.     <select id='item_select' name='item'>
            <option value='0'>- please choose -</option>
            <option value='1'>Car</option>
            <option value='2'>Train</option>
        </select>




Depending on above selection, a window pops up with the direcetions in it.

The Problem: I don't know how to do a simple if () function with this array. With the example below, always both popus are opened (for the journey with car and train)

  1. //This section displays a div depending on the selection
  2.  $(document).ready(function() {

        var message = new Array();

        message[1] = "<input type='checkbox' name='checkbox_window' disabled='true'/>";
        message[2] = "<input type='checkbox' name='checkbox_window' checked='checked' />";
     
        $(document).ready(function(){
        $("#item_select").change(function()
        {
                var message_index

                message_index = $("#item_select").val();
                $("#message_display").empty();

                if (message_index > 0)
                    $("#message_display").append(message[message_index]);
            });
         });

    // This section opens a popup with a new website (if ticked)

    $(document).ready(function () {
     $('form').submit(function(){
             var f=$(this), from;
             if (f.find('input[name=checkbox_window]:checked').length) {
                     from = f.find('input[name=start_send]').val();


























  3. // This if function should open a different URL depending on the selection (does not work)
                     if (message_index = 1) {
                window.open('http://maps.google.com/?&q='+ encodeURIComponent(from) +'+to+LA');
                }
                 if (message_index = 2) {
                window.open('http://traintimes.com/?start='+ encodeURIComponent(from) +'&dest=LA');
                     return false;
             }

     });
    }); 










Does anybody know how to work that out?

Thanks for every hint!

Scotty