Jump to content

How can i add link to select option


goodtech
 Share

Recommended Posts

hi guys i have this code

---------------------------

$caseSelect = new SelectBox('only for test','');$caseSelect->addItem('car1')           ->addItem('car2')           ->addItem('car3')           ->addItem('car4');

---------------------------

i want to know , how can i add link (http...) to this option on select

 

 

thanks in advance

Edited by goodtech
Link to comment
Share on other sites

OMG I forgot :facepalm:

guys just u need change like bottom

$carone = '<a href="#">this car is number one</a>';$caseSelect = new SelectBox('only for test','');$caseSelect->addItem($carone)           ->addItem('car2')           ->addItem('car3')           ->addItem('car4');
Edited by goodtech
Link to comment
Share on other sites

thanks for your reply

look this link

http://tutorialzine.com/2011/11/chained-ajax-selects-jquery/

class SelectBox{	public $items = array();	public $defaultText = '';	public $title = '';		public function __construct($title, $default){		$this->defaultText = $default;		$this->title = $title;	}		public function addItem($name, $connection = NULL){		$this->items[$name] = $connection;		return $this; 	}		public function toJSON(){		return json_encode($this);	}}

---------------------

so how can i use link on this select ?

Edited by goodtech
Link to comment
Share on other sites

A better question is why you need a link in an option. If you want the page to go somewhere else when the select an item then you don't use a link for that, you use an onselect handler to get the selected option and redirect based on the option value.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...