...

View Full Version : Send User To URL If Product Is For Sale



surge42
01-07-2004, 12:56 AM
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.

Kor
01-07-2004, 10:01 AM
I guess that an if statement combined with a string split will do the job:



<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 (restore) selObj.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
01-07-2004, 11:28 AM
...or, if you have multiple ITEM_1, ITEM_2, ITEM_3 you may split it otherwise:

var parts = url.split('');
if(parts[0]=='I'){

glenngv
01-07-2004, 11:35 AM
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)">

Kor
01-07-2004, 11:41 AM
or, I reckon, better:

var parts = url.split('');
if(parts[0]!='h'){



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum