Make html select option drop down menu open by default - html

When the select box is clicked, a drop down list of options is displayed. The drop down list stays open until the user clicks outside or selects one of the options in the drop down list.
Is there a simple way of making the drop down list be displayed when user enters page? Like autofocus but better. Similar to how amazon displays it's menu automatically.
I understand that I could probably just make a ul dropdown list + javascript and etc, but was wondering whether there was a way of doing it with select using html or javascript.

you can do it with j query(but i think it is not exactly some thing that you need)
Html Code
<select class="select1" size="5" style="display:none">
<option name="test" value="" class="first">Select</option>
<option name="test" value="" class="">Opt1</option>
<option name="test" value="" class="">Opt2</option>
</select>
Java script
$(document).ready(function() {
$('.select1').toggle();
$(document).click(function(e) {
$('.select1').attr('size',0);
});
});
Demo

You can easily simulate a click on an element, but a click on a <select> won’t open up the dropdown.
Using multiple selects can be problematic. Perhaps you should consider radio buttons inside a container element which you can expand and contract as needed.

Related

How can I keep datalist showing items in the drop down menu?

If I use the normal datalist, for example, like this.
<input name="example" list="example" />
<datalist id="example">
<option value="Value1"></option>
<option value="Value2"></option>
</datalist>
When I click on an item, it starts only showing that element. And I can't go back to see all the items. How can I fix that?
Note that I don't want to use select either, because it doesn't allow me to copy an entry.
That is one of Datalist's limitations, but there are some workarounds: http://pebbleroad.github.io/combo-select/

How can I get drop down list have check button with angular?

I just started learning angular 2 and making small web page.
One important requirement is to have expanded drop down list with check button.
The drop down list has to stay expanded, show 10 elements by default and support multiple selection. so I used multiple and size attribute for it. But I can't find a way to put checkbox in front of each element.
I also thought about using checkbox control instead of select option. But as there are so so many elements, I don't know how to make only 10 items visible with scroll bar.
Below is my code. Each group has array of element object. Can anyone help me please?
<div class="blahblah">
<div class="select-wrapping hide-list" >
<select class="wide" size="10" name="groups" multiple>
<optgroup *ngFor="let group of groups" label="{{group.name}}">
<option *ngFor="let element of group.elements" [value]="element.ID">
</optgroup>
</select>
</div>
</div>

HTML input for many different options

I am making an HTML form with multiple inputs. I am using mainly select inputs (as below),
<select>
<option></option>
<option></option>
</select>
and also some radio buttons. I each input represents a different category. I have one category with 20+ possible options. I need an HTML form to do this without taking up a lot of space. Radio buttons wouldn't work, and a select input with 20+ possible options seems a bit over-the-top. Any ideas on what type of input I should use?
Or, is it possible to limit the length of the drop-down box, and have a scroll bar on the side?
As you asked:
Any ideas on what type of input I should use?
You could just use the size attribute of select:
<select size='5'>
<option>example</option>
<option>example</option>
<option>example</option>
<option>example</option>
<option>example</option>
<option>example</option>
<option>example</option>
<option>example</option>
</select>
However as you can see with this there is no longer a dropdown - but the options are still there, with a controllable limit and a scrollbar.
Consider using a freeform text input box coupled to a <datalist> element that provides a list of suggested options once the user starts typing something in the box. You should provide a <select> fallback for browsers that do not yet support <datalist>, like so:
<input type="text" name="{NameOfYourField}" list="datalist-dogs" />
<datalist id="datalist-dogs">
<select name="{NameOfYourField}">
<option>Affenpinscher</option>
<option>Afghan Hound</option>
<option>Aidi</option>
...
</select>
</datalist>
Be aware that users will be able to submit unique values. Unlikes radios and select boxes, input values are not restricted to the options provided in the datalist.
Further reading: https://developer.mozilla.org/en/docs/Web/HTML/Element/datalist
You can use CSS styling on HTML forms to scale the size down, just make sure to give the specific form elements an ID. You can use width and height commands on most [not all] types of form content. If you need the form to be really small, but then expand the form based upon user interaction, you can use JavaScript "onclick" or "onmouseover" commands to cause the form elements to expand when the user either rolls the mouse over it or clicks on it. I'm gonna show you an example of what this looks like on a submit button. The same model works with any form element
HTML form could look like this:
<input id="button" name="button" type="submit" value="Send">
CSS looks like this:
#button {
height: 5px;
width: 20px;
};
How HTML looks like with required JavaScript commands:
<input id="button" name="button" type="submit" value="Send" onmouseover="this.style.height='50px', this.style.width='200px'>

How do I create two different textareas with muliple items clickable to move between the two textareas?

I have been looking around for a couple days now and haven't found the answer. I did see this: jQuery - Copy / move text from select list to textarea which I already did, but then the problem is what if the after copying the selected drop down item to go into the text area you change your mind and want to send it back or get rid of it?
I'm not sure if it's best to use two tags or if I should use textareas. This is what I have for the field on the left:
<select size="10" name="options" variable="#available options" multiple="multiple">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</select>
And then when options are selected and the button is clicked they are added to a list and my textarea on the right reflects that list. Should I also make the area on the right a selectable drop down similar to the one with all my options? If I do that, then how to I get it to reflect only the options I have clicked?
Sorry if this doesn't make sense. It's my first time posting here and I'm not a programmer (but learning). Thanks in advance!

Submit form when selected value of select element is changed without javascript

Hi the question is pretty simple.
<select name="justanumber">
<option value="1" selected="selected">1</option>
<option value="2"></option>
</select>
when selected value is changed i have to do a form post.
But the problem is to do this WITHOUT javascript.
I'm not sure is it possible to do that, the best result i have archived is submit form using label for.
No, that is not possible without using client script.
I suggest that you use script for how you want it to work normally, and supply a submit button as a backup for those who can't use script.
No, there is no auto-submit attribute for such things -- however, there is a way around it:
CSS:
#jsOn .Submit {
display: none;
}
HTML:
<form id="my_form" action="">
<select id="justanumber" name="justanumber">
<option value="1" selected="selected">1</option>
<option value="2"></option>
</select>
<input type="submit" value="Go!" class="Submit" />
</form>
JavaScript:
var visible_root = document.getElementsByTagName("body");
while (visible_root.length < 1) {
continue;
}
visible_root = visible_root[0];
visible_root.id = "jsOn";
document.getElementById("justanumber").onchange = function() {
document.getElementById("my_form").submit();
};
When people without JavaScript arrive at your site they will see a submit button. When people with JavaScript turned on arrive at your site the submit button will be hidden and an onchange event will be added to the select element. (Alternately you could add an event listener, if you have a JavaScript library that normalizes all of the events for you.)
I don't believe this is possible without js. An obvious approach would be to set a submit button as the option's value (eg, <option><input type="submit"></option>). Unfortunately browsers will bark and moan, appending the input element after the select element. If the select determines the app flow, consider using another another UI element (eg, buttons, links, etc.).
Here is the answer.
Unfortunately, It's not possible.
<form action="aaa.php" method="post" name="autosubmit_select">
<select name="justanumber" onChange="document.autosubmit_select.submit();">
<option value="1" selected="selected">1</option>
<option value="2"></option>
</select>
</form>
agreed you must use javascript for this
please see this post How to submit form on change of dropdown list?
if your worried about users not having javascript enabled then i would suggest along with the given example in the post in the link you do this
<noscript>This form requires that you have javascript enabled to work properly please enable javascript in your browser.</noscript>
or something along those lines
other than that it is not possible to do this (currently) without the use of javascript
use a submit_button to submit while JS not enabled.
If JS enabled hide the button using JavaScript. Amazon did so.!
http://www.amazon.in/s/ref=nb_sb_ss_i_1_5?url=search-alias%3Delectronics&field-keywords=sd+card&sprefix=sd+ca%2Celectronics%2C401&crid=1M4KMJEGDLTEL
disable JS and see the sortby section top right corner.