goodtech Posted August 25, 2015 Share Posted August 25, 2015 (edited) 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 August 26, 2015 by goodtech Link to comment Share on other sites More sharing options...
goodtech Posted August 25, 2015 Author Share Posted August 25, 2015 (edited) OMG I forgot 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 August 26, 2015 by goodtech Link to comment Share on other sites More sharing options...
goodtech Posted August 25, 2015 Author Share Posted August 25, 2015 Link does not work again on select option ouch Link to comment Share on other sites More sharing options...
justsomeguy Posted August 25, 2015 Share Posted August 25, 2015 What is the SelectBox class? If that makes a normal select element, you can't have links inside options. 1 Link to comment Share on other sites More sharing options...
goodtech Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) 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 August 26, 2015 by goodtech Link to comment Share on other sites More sharing options...
justsomeguy Posted August 26, 2015 Share Posted August 26, 2015 That tutorial uses regular select elements, so you can't put a link in them. You would need to find some Javascript that makes a fake select box using divs and other things that you can put arbitrary content into. 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 26, 2015 Share Posted August 26, 2015 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. 1 Link to comment Share on other sites More sharing options...
goodtech Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) Thanks alot mate I found better selected box https://github.com/tuupola/jquery_chained Edited August 26, 2015 by goodtech Link to comment Share on other sites More sharing options...
Chikwado Posted August 31, 2015 Share Posted August 31, 2015 Can you show the code that work for you? I have a javascript code that I use to bind in select option which work for me. Those jquery example do not seem to work. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now