www.webdeveloper.com
Results 1 to 2 of 2

Thread: Injecting Select Option Selected Values to build a search URL

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Injecting Select Option Selected Values to build a search URL

    I'm trying to basically take 2 parts of a search URL and add the option selections in the middle to create an overall working search URL.
    For some reason the way I'm trying to target the options selected values is not working, and causing the whole href.location to not work at all.

    Can anyone tell me what's wrong with my onClick in the Submit button?

    Code:
    <form name="redlinesearch">
    <select name="redline_inches" id="redline_inches">
    <option value="14x+">14"</option>
    <option value="15x+">15"</option>
    <option value="16x+">16"</option>
    <option value="17x+">17"</option>
    <option value="18x+">18"</option>
    <option value="20x+">20"</option>
    <option value="22x+">22"</option>
    <option value="24x+">24"</option>
    <option value="26x+">26"</option>
    <option value="28x+">28"</option>
    <option value="30x+">30"</option>
    </select>
    
    <select name="redline_boltpattern" id="redline_boltpattern">
    <option value="4-100">4-100</option>
    <option value="4-108">4-108</option>
    <option value="4-114.3">4-114.3</option>
    <option value="5-100">5-100</option>
    <option value="5-108">5-108</option>
    <option value="5-110">5-110</option>
    <option value="5-112">5-112</option>
    <option value="5-114.3">5-114.3</option>
    <option value="5-115">5-115</option>
    <option value="5-120">5-120</option>
    <option value="5-127">5-127</option>
    <option value="5-135">5-135</option>
    <option value="5-139.7">5-139.7</option>
    <option value="5-150">5-150</option>
    <option value="6-127">6-127</option>
    <option value="6-135">6-135</option>
    <option value="6-139.7">6-139.7</option>
    <option value="8-165">8-165</option>
    <option value="8-170">8-170</option>
    </select>
    
    
    <input type="submit" value="Search Now" onClick="location.href='http://www.redlinewheel.com/index.php?search_performed=Y&match=all&q='+redline_inches.options[selectedIndex].value+'+'+redline_boltpattern.options[selectedIndex].value+'+'&pname=N&pfull=Y&cid=0&pcode=&price_from=&price_to=&weight_from=&weight_to=&dispatch[products.search]=Search'" />
    
    </form>

  2. #2
    Join Date
    Jan 2013
    Posts
    2
    I tried a new version, pretty much acting the same. I know this is basic stuff and I'm just not much of a Javascripter... any help would be appreciated.


    Code:
    <form name="redlinesearch">
    <select name="redline_inches" id="redline_inches">
    <option value="14x+">14"</option>
    <option value="15x+">15"</option>
    <option value="16x+">16"</option>
    <option value="17x+">17"</option>
    <option value="18x+">18"</option>
    <option value="20x+">20"</option>
    <option value="22x+">22"</option>
    <option value="24x+">24"</option>
    <option value="26x+">26"</option>
    <option value="28x+">28"</option>
    <option value="30x+">30"</option>
    </select>
    
    <select name="redline_boltpattern" id="redline_boltpattern">
    <option value="4-100">4-100</option>
    <option value="4-108">4-108</option>
    <option value="4-114.3">4-114.3</option>
    <option value="5-100">5-100</option>
    <option value="5-108">5-108</option>
    <option value="5-110">5-110</option>
    <option value="5-112">5-112</option>
    <option value="5-114.3">5-114.3</option>
    <option value="5-115">5-115</option>
    <option value="5-120">5-120</option>
    <option value="5-127">5-127</option>
    <option value="5-135">5-135</option>
    <option value="5-139.7">5-139.7</option>
    <option value="5-150">5-150</option>
    <option value="6-127">6-127</option>
    <option value="6-135">6-135</option>
    <option value="6-139.7">6-139.7</option>
    <option value="8-165">8-165</option>
    <option value="8-170">8-170</option>
    </select>
    
    
    <input type="submit" value="Search Now" onClick="RedLineQuery()" />
    
    </form>
    
    
    <script>
    function RedLineQuery ()
    {
    	var ri = document.getElementById("redline_inches");
    	var rb = document.getElementById("redline_boltpattern");
    	var ri_q = ri.options[ri.selectedIndex].value;
    	var rb_q = rb.options[rb.selectedIndex].value;
    	location.href='http://www.redlinewheel.com/index.php?search_performed=Y&match=all&q='+ri_q+rb_q'&pname=N&pfull=Y&cid=0&pcode=&price_from=&price_to=&weight_from=&weight_to=&dispatch[products.search]=Search'"
    </script>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles