I have the following code currently:

<?php foreach ((array)$node->field_buy_at as $item) { ?>
<?php print $item['view'] ?>
<?php } ?> 

I would like to make the list a drop down with a link so that when a user selects, he goes to a new page. I tried the following:

        <select name="select">
      	<?php foreach ((array)$node->field_buy_at as $item) { ?>
	<?php 
            $url = $node->field_buy_at[0]['url'];
            $store = $item['view']; 
         ?>
        <? echo "<option value='$url'>$store</option>";?>
		<?php } ?> 
	  </select>

I'm pretty sure it's this "$url = $node->field_buy_at[0]['url'];" that I don't have correct.

And, what do I need it to have so that it opens to a new window?

Comments

zeta1600’s picture

Open in same window:

      <!-- Pull Down Store -->
      <select onChange="window.location='<? print ($url); ?>'+this.value">
      	<?php foreach ((array)$node->field_buy_at as $item) { ?>
		<?php
        $store = $item['display_title'];
		$url = $item['display_url'];
		?>
        <? echo "<option value='$url'>$store</option>";?>
		<?php } ?> 
	  </select>
      <!-- Pull Down Store -->

Open it in a new window:

<form action="../">
	<select name="myDestination"
    onchange="this.form.WINDOW_NAMER.value++;
    ob=this.form.myDestination;
    window.open(ob.options[ob.selectedIndex].value
    ,'Window_Name'+this.value)">      	
	<?php foreach ((array)$node->field_buy_at as $item) { ?>
		<?php
        $store = $item['display_title'];
		$url = $item['display_url'];
		?>
        <? echo "<option value='$url' target='_blank'>$store</option>";?>
		<?php } ?> 
	  </select>
      <input name="WINDOW_NAMER" type="HIDDEN" value="1">
      </form>
zeta1600’s picture