Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Looking for mutiple level pulldown menu with a twist


Fotiman - 1:10 pm on Mar 18, 2010 (gmt 0)



In this case for my two examples would return

Region 1 + Category 1 = r='1'&c='1'
Province 3 + Category 3 = p='3'&c='3'

Close. In my example, the string would end up looking like this:
http://www.example.com/yourSearchPage.php?r=1&c=1

(assuming you selected the options with value 1 for both of those items)

Of course I need to replace r/p/c with whatever my software uses for those parameters.

Correct. That's why I asked if you had a server side page in place already to process the form.


Can I ask, why are the "+" necessary? Why not write r='regions.value'&c='categories.value'?

In JavaScript, the + is the concatenation operator. So to concatenate values into a string, you need that in there. Without it, you would get a syntax error. And correct, there would be no trailing + as you have nothing else to concatenate.

JavaScript is case sensitive, so yes, case is important.


And finally, I replace "alert('province search')" with what in order for it to execute the url directly?


location = 'http://www.example.com/yourSearchPage.php?r=' + regions.value + '&c=' + categories.value;

or

location = 'http://www.example.com/yourSearchPage.php?p=' + provinces.value + '&c=' + categories.value;

(depending on which search you were doing).


Thread source:: http://www.webmasterworld.com/javascript/4097032.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com