Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Send User To URL If Product Is For Sale

    I have a page that asks customers to vote for products they want to see for sale in the near future.
    The products are listed in a pull down. I use a script from http://www.bignosebird.com that collects the votes via a Perl script.

    here's what the pull down looks like.


    <select name="ITEM_1" size="22" id="select7">

    <option value="ITEM_1|No Vote Sent">- - Select Products For 2004 - -</option>
    <option value="ITEM_1|Hard Drives">Hard Drives</option>
    <option value="ITEM_1|iPod">iPod</option>
    <option value="ITEM_1|Computer cases">Computer cases</option>
    <option value="ITEM_1|Memory Sticks">Memory Sticks</option>

    </select>

    FYI: The value "ITEM_1" allows the script to tally the votes for that specific pull down.

    My objective is to send the user to a page if the product is already available for sale at our store. For example If the customer chooses to vote for iPod,

    is there a way to Have an onBlur (or onChange I guess) event that would send them to a page providing promotional info about our iPods?


    I'm guessing the best way to approach the solution is to use URL to the iPod sales page as the value.


    <option value="http://www.link_to_iPod_sales_page.html">I Pod</option>

    I've tried to use Dreamweaver's Jump menu script but it wont work because when the customer wants to vote on a product that's not at our store the script

    still uses the value as a link. See below for an example



    <script>

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    </script>


    <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">

    <option value="ITEM_1|No Vote Sent">- - Select Products For 2004 - -</option> > BAD LINK <
    <option value="ITEM_1|Hard Drives">Hard Drives</option> > BAD LINK <
    <option value="http://www.apple.com/iPod/">iPod</option> > GOOD LINK <
    <option value="ITEM_1|Computer cases">Computer cases</option> > BAD LINK <
    <option value="ITEM_1|Memory Sticks">Memory Sticks</option> > BAD LINK <

    </select>


    Could you provide a script solution that does not try to use value ="ITEM_1|any product not available for sale" as a link but will if the value is

    value="http://link to any product available for sale ?

    Know of any examples on the net that come close to this request? I've been looking high and low and have found nothing close.
    Don't Stop Learning!

    Never Give Up!

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I guess that an if statement combined with a string split will do the job:

    PHP Code:
    <html>
    <
    head>
    <
    script>
    function 
    MM_jumpMenu(targ,selObj,restore){ //v3.0
    var url selObj.options[selObj.selectedIndex].value;
    var 
    parts url.split('|');
    if(
    parts[0]=='ITEM_1'){
    return 
    false
    }
    else {
    eval(
    targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (
    restoreselObj.selectedIndex=0;
    return 
    true
    }
    }
    </script>
    </head>

    <body>
    <select name="menu1" onChange="return MM_jumpMenu('parent',this,0)">

    <option value="ITEM_1|No Vote Sent">- - Select Products For 2004 - -</option> 
    <option value="ITEM_1|Hard Drives">Hard Drives</option> 
    <option value="http://www.apple.com/iPod/">iPod</option> 
    <option value="ITEM_1|Computer cases">Computer cases</option> 
    <option value="ITEM_1|Memory Sticks">Memory Sticks</option> 

    </select>

    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    ...or, if you have multiple ITEM_1, ITEM_2, ITEM_3 you may split it otherwise:

    var parts = url.split('');
    if(parts[0]=='I'){
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    eval() is unnecessary:

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    targ.location=selObj.options[selObj.selectedIndex].value;
    if (restore) selObj.selectedIndex=0;
    }
    ...
    <select name="menu1" onChange="return MM_jumpMenu(parent, this, 0)">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    or, I reckon, better:

    var parts = url.split('');
    if(parts[0]!='h'){
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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