Adding a button to select dropdown - javascript

I'm currently using selectize.js for my dropdown and I would like to add a button at the end of the option list like this
I tried adding a span into the select group but it doesn't show up in the dropdown. How should I change my code to allow a button at the end of the option like shown in the picture?
$('#client').selectize();
<div class="form-group">
<label>Client</label>
<select id="client" type="text">
<option value="0">Add New Client</option>
<option value="1">Client 1</option>
<option value="2">Client 2</option>
<option value="3">Client 3</option>
</select>
<span class="input-group-addon" id="clear_addon">Clear</span>
</div>

You can modify the plugin's html and append a button after the items list:
$('.selectize-dropdown').append('<button id="clear_addon">Clear</button>');

Related

Unselect all elements from a Materialize multiple dropdown except first

I have a multi-select drop down as following, where I have selected the multiple options.
<select class="select2 mysql_attr" id="mysql_attr" name="mysql_attr[]" title="Student " multiple >
<option value="0"> All</option>
<option value="1">Sub 1</option>
<option value="2">Sub 2</option>
<option value="3">Sub 3</option>
<option value="4">Sub 4</option>
</select>
I have a first option called "All". When this option is clicked i want all selected items should be deselected except this and if other options click this option should be deselect.
I Search a lot but din't find anything.
How can I accomplish this using Materialize?

How to Add two Select tags with Submit button to Jump to url URL

I'm trying to setting up a dropdown menu selector.
When visitor choose "Volvo" from the first dropdown menu and choose "White" from the second dropdown menu then hit submit button. He should jump to URL 1, and so on.
Can I do this?
<body>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<select>
<option value="white">White</option>
<option value="black">Black</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
</select>
</body>
<form target="_blank" action="/page_url" method="get">
<select name="carbrand">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel" selected="selected">Opel</option>
<option value="audi">Audi</option>
</select>
<select name="carcolor">
<option value="white">White</option>
<option value="black">Black</option>
<option value="red" selected="selected">Red</option>
<option value="blue">Blue</option>
</select>
<br/><br/>
<input type="submit" value="Submit">
</form>
You could use form and input tags.
As above example, after clicking on the button a new page will open (target="_blank" attribute opens the URL in a new window or tab).
In this case using the method="get" form attribute, the values of the dropdowns are passed as parameters in URI /page_url?carbrand=opel&carcolor=red. If instead the method="post" form attribute used, the values of the dropdowns aren't present in the URL.
You can put your drop downs into a form, that way when the form is submitted (with your submit button), you can then use the form values to determine what content to load.
Alternatively, if you want to do this without the server side logic, you replace your submit button with a simple <button type="button"...> and have the on click of that button handle the logic to open the page you want.
I think you should use this like this :
<option value="volvo"><a href='http://example.com'>Volvo</a></option>
</select>```

Default blank option on <select> for Safari

I'm trying to make a <select> where the first <option> is empty, it is not visible in the dropdown and not selectable.
I've been researching for like 4 hours. I saw so many working options but the thing is that none of them (or at least what I've found) are working on Safari.
This is my code:
<select class="custom-select" formControlName="subindustryName">
<option *ngFor="let subindustry of subIndustries" [value]="subindustry.value">
{{subindustry.label}}
</option>
</select>
I'm not using jQuery.
would this work for you? you can set style properties for an option and disable the field so it's not selectable anymore. this question seems to have been answered with another post. default empty option.
<select>
<option disabled selected value style="display:none"></option>
<option value="one">one</option>
<option value="two">three</option>
</select>
Just add option with value undefined to force angular to select that value. like below
<select class="custom-select" formControlName="subindustryName">
<option value="undefined"></option>
<option *ngFor="let subindustry of subIndustries"
[value]="subindustry.value">{{subindustry.label}}</option>
</select>
and with if you want to it to be not selectable then add 'disabled' attribute with that.
EDIT AS PER COMMENT
so whatever you pasted in question should work.
Here is my code snippet which is working..
<div class="form-group">
<label class="col-md-3 control-label">Gender</label>
<div class="col-md-3">
<select id="gender" class="form-control" [(ngModel)]="userModel.gender" name="gender" required >
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</div>
</div>
Just try with template driven approach for 'subindustryName' and check.
<option disabled selected value>Select Option</option>
<option value="one">one</option>
<option value="two">two</option>
In both Safari and Chrome, default disabled selected value is this.
if you use like.
<select>
<option> Select Option </option>
<!-- replace above code with -->
<option value='' selected> Select Option </option>
</select>
Hope this will work.

CasperJS - Select dropdown menu without id or class only by value

I am trying to select a dropdown menu only by value (no id or class) using CasperJS
Here is the html code:
<div class="select select-large select-block">
<select>
<option value="31110674">Details 1</option>
<option value="1346954">Details 2</option>
</select>
</div>
Any help would be appreciated!

HTML: Is there a way to allow the user to type in their input but also have a drop down select menu?

For example, I have
<label class="form">Menu</label>
<select id="selection" name="select" required>
<option value="" selected>--Select an Option--</option>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
...
</select>
This would only give a a drop down menu when the user clicks on the input box with their mouse. But I want to give them the option to be able to type in the input box such as:
If the user types in option1 it would direct them to the "Option 1" drop-down menu, etc. And if the user types in any other words that are not included in the drop-down list it would show "Invalid Input".
Yes there is! A text input with a list attribute:
<input type="text" name="city" list="cityname">
<datalist id="cityname">
<option value="Boston">
<option value="Cambridge">
</datalist>
EDIT: for the autocomplete, try Bootstrap Typeahead

Categories