Results 1 to 2 of 2

Thread: Javascript Firefox to IE woes...

  1. #1
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript Firefox to IE woes...

    Ok, so I have a very simple form, which is activated by very simple javascript, and it works in Firefox but not in Internet Explorer. Are there any guns out there who can convert this into a cross-platform masterpiece?

    Code:
    <script type="text/javascript">
    function vipRedirect(artist)
    {
    var initial = "http://www.hubartistservices.com/backstage/VIP_";
    document.vipContent.action=initial+artist;
    }
    </script>
    
    <form name="vipContent" method="post" onSubmit="javascript:vipRedirect(this.artist.value);">
                
           <table width="270" border="0" cellpadding="5" cellspacing="0">
             <tr>
               <td width="100" align="right">Artist:</td>
               <td width="75"><select name="artist" class="fontmain" type="text" value="">
                 <option>Dappled Cities</option>
                 <option>Old Man River</option>
                 <option>Shelley Harland</option>
                 <option>The Seabellies</option>
                 <option>The Curse of Company</option>
                 <option>Washington</option>
               </select></td>
               <td width="75"><input type="submit" class="fontmain" value="Get VIP content" /></td>
             </tr>
           </table>
    </form>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There are a number of other, better ways to go about this, but the main problem with the method you are trying is that there is no value to the select in IE unless it's options have values. So this will work in IE and FF and others with javascript enabled:

    Code:
    <script type="text/javascript">
    function vipRedirect(artist){
    var initial = "http://www.hubartistservices.com/backstage/VIP_";
    document.vipContent.action=initial+artist;
    return true;
    }
    </script>
    
    <form name="vipContent" method="post" onsubmit="return vipRedirect(this.artist.value);">
                
           <table width="270" border="0" cellpadding="5" cellspacing="0">
             <tr>
               <td width="100" align="right">Artist:</td>
               <td width="75"><select name="artist" class="fontmain" type="text">
                 <option value="Dappled Cities">Dappled Cities</option>
                 <option value="Old Man River">Old Man River</option>
                 <option value="Shelley Harland">Shelley Harland</option>
                 <option value="The Seabellies">The Seabellies</option>
                 <option value="The Curse of Company">The Curse of Company</option>
                 <option value="Washington">Washington</option>
               </select></td>
               <td width="75"><input type="submit" class="fontmain" value="Get VIP content"></td>
             </tr>
           </table>
    </form>
    However, with PHP or another server side language (if available), you could make the form work without javascript and would only need a single 'receiving' page. That would probably be best because then your users could navigate without needing to have javascript. Failing that, there are a number of more straightforward methods to accomplish this via javascript. Or - instead of a form, why not links? If space is a premium, the links could be in a pseudo select (possibly powered only by css or with javascript that could fall back to ordinary links if javascript were unavailable) that wouldn't require javascript or a server side language.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •