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

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!

Related

Can't select multi-select items. Jquery

I have implemented the following multiselect into my project.
http://loudev.com/
And I have done everything as I should (as far as I know) the layout is looking as it should, the css and javascript is running but when i hover over an option, it isn't clickable, it treats it as a line of text, not a clickable object.
Here is the code for the select input and where it is initialised in javascript.
<select multiple="multiple" class="form-control" id="my-select" name="my-select[]">
<option value="elem_1">elem 1</option>
<option value="elem_2">elem 2</option>
<option value="elem_3">elem 3</option>
<option value="elem_4">elem 4</option>
<option value="elem_100">elem 100</option>
</select>
$('#my-select').multiSelect();

Adding a button to select dropdown

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>');

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?

Programmatically keypress on a focused drop-down element without Jquery

I'm trying to press enter (programmatically) on a drop down element. I CANNOT USE JQUERY.
The drop down is already in focus, I just want to click enter to open it.
Any ideas how it can be achieved?
Here's my HTML:
<select class="test">
<option value="1">item1</option>
<option value="2">item2</option>
<option value="3">item3</option>
<option value="4">item4</option>
<option value="5">item5</option>
<option value="6">item6</option>
</select>
And the JS that got the element focused:
document.getElementsByClassName('test')[0].focus();
var element = document.getElementsByClassName('test');
element.onclick.apply(element);

Show/Hide Div in JQuery for three select option

<select name='main'>
<option value='For Sale'>For Sale</option>
<option value='Community'>Community</option>
</select>
<select name='sub'>
<option value='Animal'>Animal</option>
<option value='Fish'>Fish</option>
</select>
<select name='sub'>
<option value='Friend'>Friend</option>
<option value='Relitive'>Relitive</option>
</select>
<select name='sub2'>
<option value='Animal Thing'>Animal Thing</option>
<option value='Fish Thing'>Fish Thing</option>
</select>
<select name='sub'>
<option value='Best Friend'>Best Friend</option>
<option value='Relitive Home'>Relitive Home</option>
</select>
This is my html code and I want that when the user selects the main menu it will then show the sub menu and when the user selects the sub menu it will then show sub2 menu. I want to do this with Jquery, can someone help me with this?
I'm supposing that the sub and sub2 classes are disabled / hidden?
You want to check if the user has selected a value in the main.
You can find this in the Jquery documentation :selected Selector
So now you can see if you're main select was selected and then you can use this to enable to next select sub
If you want furthermore details on Selector, I think this question How to check if an option is selected? has some solid answers.
Cheers!

Categories