By sprugman on
What's the drupal way of producing this code (which does select box navigation)?
<select onchange="navigate()">
<option value="url1">Place 1</option>
<option value="url2">Place 2</option>
<option value="url3">Place 3</option>
</select>
Assuming I have two parallel arrays with urls and labels.
Ordinarily, I would just iterate through the arrays and build my options list, but it seems like there must be a more drupal-like way of handling this.
Comments
What's the Question?
I'm not completely understanding the question, but if you have two arrays one for keys and one for values us array_combine(). If this is a form your probably using form api. So you would feed your combined array as options to the form array. If your wanting your user to navigate the site using the select then you would use hook_submit find out what value was selected then use drupal_goto() depending on which option was selected. More information can on drupal's Form API can be found at http://api.drupal.org/api/file/forms_api_reference.html/5.
Cheers,
-mpare
--
Pare Technologies
Drupal Consulting, Themeing, and Module Development
806.781.8324 | 806.733.3025
www.paretech.com
Figure Something Out? Document Your Success!
create javascript "jump navigation" select box in a block...
Here's something I did that might help someone else. Using Drupal 5.x
I created a block to show a select box menu that immediately takes the user to the node/item selected. Next I want to figure out how to pop that block into a view that also needs to use it, but that's another issue. Here's my code in the Block Body set to Input Format of 'PHP code':
(Make sure that javascript 'onchange' line doesn't have any spaces in it.)
Hope that helps someone...