Jump to content

[SOLVED] Text menu


ctcp

Recommended Posts

  <form method="GET" action="http://google.gr">
			  <input name="query1" type="text" id="inputString" autocomplete="off" onblur="fill();" onkeyup="lookup(this.value);" size="30" />
	      <label for="type"></label>
<select name="type" id="type">
  <option value="Games" <?php if (!(strcmp("Games", $type))) {echo "selected=\"selected\"";} ?>>Games</option>
  <option value="Apps" <?php if (!(strcmp("Apps", $type))) {echo "selected=\"selected\"";} ?>>Apps</option>
</select>
<button type="submit">Search</button>

How To..

if i select Games --> go to games.google.com

if i select Apps  --> go  to apps.google.com

Link to comment
https://forums.phpfreaks.com/topic/167947-solved-text-menu/
Share on other sites

I'm not 100% sure what you're trying to do here but I think maybe this is what you'd want:

 

<select name="type" id="type" onChange="location.href='http://'+this.options[this.selectedIndex].value;">
  <option value="games.google.com">Games</option>
  <option value="apps.google.com">Apps</option>
</select>

Link to comment
https://forums.phpfreaks.com/topic/167947-solved-text-menu/#findComment-885801
Share on other sites

Most would advice JavaScript and the onchange event, however for usabilities sake I discourage this, use this instead:

 

$query = $_POST['query'];
$type = $_POST['type'];
switch ($type) {
    case 'games':
        header('Location: http://games.google.com?q=' . $query);
        break;
    case 'apps':
        header('Location: http://apps.google.com?q=' . $query);
        break;
}

Link to comment
https://forums.phpfreaks.com/topic/167947-solved-text-menu/#findComment-885819
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.