I have kept a Custom select box in a Table Td cell, which when clicked opens a list of two custom options. Adding a row to the table creates another instance of the same Custom select box whose functionality is same as above.
<div class="multiselect">
<div class="InternetselectBox" id="Connectivity_COld9_InternetFacilityDiv_1" onclick="showInternetLocationCheckboxes(this)">
<select class="location_select" style="color: #666;" id="Connectivity_COld9_InternetFacility_1">
<option value="0"> 2 Location Selected</option>
</select>
<div class="overSelect"></div>
</div>
<div class="MultiSelect_checkboxes InternetMultiSelect" id="Connectivity_COld9_MultiSelect_checkboxes_1" style="display: block;">
<label for="Connectivity_COld9_InternetFacilityCHK_1_1">
<input type="checkbox" checked="checked" id="Connectivity_COld9_InternetFacilityCHK_1_1" name="lineup[]" onclick="InternetDynamicCheckboxCount(this)">
TCO
</label>
<label for="Connectivity_COld9_InternetFacilityCHK_1_2">
<input type="checkbox" checked="checked" id="Connectivity_COld9_InternetFacilityCHK_1_2" name="lineup[]" onclick="InternetDynamicCheckboxCount(this)">
MEPS
</label>
</div>
</div>
The issue is, when I click on the select box, and scroll the page or that particular div(table div), the drop down menu also moves along with the scrolling direction. I have a little bit of confusion with using Css style of Position
And when I add row and scroll down, the drop down also moves along.
Help me in resolving this issue. I want a drop down to appear just when I click the drop down and not move when I scroll down or up.
I tried to use css property position: relative to the drop down. But, it displaces or expands other Td of the same row. I do not need this.
Any css class needs to be added. Let me know. Any help is appreciated.
Related
I've been running around trying to figure out how I can use grid to format the layout of a form. I seem to be doing exactly what other coders are doing to utilize grid in CSS but it's just not working. My goal is to put the "type" selector to the right of the pet name and the reset button to the right of the submit button. Could someone point out what I'm missing?
my css code and what the form looks like
The HTML for the form
I think your issue might be because of the <div> you have on both input and select tags. By default div are block elements and browsers will start div on a new line by placing a line break before and after a div.
One quick fix is removing the div surrounding your Pet Name and
Type. If you must, have both of them in a single div.
Preferably use 1fr in place of 50%.
You will get this desired output
You are using seperate div for individual elements, that's why the elements are displaying one after another. You can put a common div for the elements which you want to display adjacent to each other.
<div class="grid">
<div>
<legend>Add pet</legend>
</div>
<div>
<label for="Name">Pet Name</label>
<input type="text" id="name" name="pet_name">
<label for="Type"></label>
<select id="type" name="pet_type">
<option value="Cat">Cat<option>
<option value="Dog">Dog<option>
<option value="Dog">Dog<option>
<option value="Dog">Dog<option>
</select>
</div>
<div>
<button type="submit" id="new_pet_submit_button">Create New Pet</button>
<button type="reset">Reset</button>
</div>
</div>
I am trying to build a basic colorpicker with predefined colors.
for that I have an object "colors" with color-values as it's properties:
public colors = [
{ value: '#ffffff' },
{ value: '#919191' },
{ value: '#555555' },
// and some more
];
Following some examples on the web, I set up a select-option structure in my html:
<select name="role" [(ngModel)]="item.color">
<option *ngFor="let color of colors" [value]="color.value">
<div class="color-box-modal" [style.background]="color.value"></div>
</option>
</select>
This does create a dropdown menu for the options, though the colors inside don't show up. The class color-box-modal has height and width values as I did not intend to have a dropdown, but several colored boxes to click on in order to select.
Is there an alternative to the select-option structure which allows me to not have a dropdown, but just several colored boxes? Radio-buttons/checkboxes are not the desirerable way either, as I want to have a clickable field on it's own that reacts to being clicked.
If there is no alternative, is it possible to do the ngModel binding on a button-click?
edit:
After testing option 2 on Osman Ceas answer, I now have this:
<ng-template #content let-c="close" let-d="dismiss">
<i class="close icon" (click)="d('Close click x')"></i>
<div class="header">
Choose a new color
</div>
<div class="content">
<label for="col1" class="color-box-modal" style="background-color: #ffffff">
<input (click)="c('#ffffff')" id="col1" type="radio" class="hidden" [(ngModel)]="item.color" [value]="'#ffffff'">
</label>
<label for="col2" class="color-box-modal" style="background-color: #ffff00">
<input (click)="c('#ffff00')" id="col2" type="radio" class="hidden" [(ngModel)]="item.color" [value]="'#ffff00'">
</label>
<label for="col3" class="color-box-modal" style="background-color: #00ffff">
<input (click)="c('#00ffff')" id="col3" type="radio" class="hidden" [(ngModel)]="item.color" [value]="'#00ffff'">
</label>
</div>
<div class="actions">
<div class="ui button" (click)="c('Close click cancel')">Cancel</div>
</div>
</ng-template>
Though the ngModel binding does not seem to work.
The whole thing opens in a modal (the template), which in itself works, just binding to the ngModel, as I said, does not.
A native HTML select will only render text inside and any other tag will be ignored, so that's why your boxes are not showing.
If your wrap your radio button or checkbox in a <label> with the attribute for equals to an ID given to the <input>, you can basically click anywhere on the label, lets say some adjacent text, and the click will propagate to the input so the binding will still work.
You can create your own custom form controls, check out this article. So you could create a custom color picker form element that will work in any form using template forms or reactive forms.
Have a nice day
Now, this might not help everyone, but it was my solution in the end.
I started with a loop, item of items where the template in my question was meant for one single item.
I solved, or rather worked around the binding situation by just moving each item to it's own component, somewhat like this:
<div *ngFor="let item of items>
<app-sub-item [item]="item"></app-sub-item>
</div>
inside I have severel of these:
<label for="col1" class="color-box-modal" style="background-color: #ffffff">
<input (click)="setColor('#ffffff')" id="col1" type="radio" class="hidden">
</label>
With the following being in the ts-file:
setColor(color: string) {
this.item.color = color;
}
This actually works just fine at the moment.
Hope whoever reads this issue can find some use in my solution.
So, I decided to make page where all content is in hidden DIV. Basicly page start blank without any content. After clicking on radio-buttons it show one DIV, and hide another.
This is buttun named "Button_name" that will open "opt3" div's content.
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" value="opt3"/>
<label for="tab-3" class="tab-label-3"> BUTTON_NAME </label>
After clicking this will open "opt3" div:
<div id="opt3" class="desc" style="display: none;">
content of div
</div>
And now:
How to make some text appear in new DIV when page is opened (or refreshed by F5), but closed directly after clicked any button in menu options?
EDIT:
Script for buttons
$(document).ready(function(){
$("input[name=radio-set]").change(function() {
var test = $(this).val();
$(".desc").hide();
$("#"+test).show();
});
});
OK I figure it out in easiest way, I think!
If someone want same effect as me - you just have to put in main div (where any other div will show after clicking on menu buttons) normal "opt" div, but without display:none.
<div id="opt20" class="desc" >
Ble ble 20
</div>
This will show "ble ble 20" only when page start, and after clicking on any menu button will hide away. Be sure that in future, you will not use again "opt20" button, because it will show you your start content.
There are tons of tutorials and info on jQuery. It really takes playing with it and studying the different options it has. Here is a quick sample of what you can do. Not exactly what you might need, but it might give you a start. jQuery is quite powerful. You will have to include the jQuery library js file in your code. http://jquery.com/
Some HTML
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" value="opt3"/> Check me
<br /><input id="btn1" type="button" value="Click Me">
<div id="opt3" class="desc" style="display: none;">
I'm opt3 hidden from the start
</div>
<div id="otherdiv" class="desc" style="display: none;">
some other div that is shown when opt3 is clicked
</div>
and the jQuery
$(document).ready(function(){
$("#btn1").click(function(){
$("#opt3").show();
if($("#otherdiv").is(':visible')){
$("#otherdiv").hide();
}
});
$("#tab-3").change(function(){
$("#otherdiv").show();
if($("#opt3").is(':visible')){
$("#opt3").hide();
}
});
});
See it in action http://jsfiddle.net/8fUXW/1/
BTW Google specific things you need then piece them together instead of trying to find an exact solution. That would be pretty difficult.
Gmail has the feature where you can select labels using checkboxes and it is hidden inside a div element where you can scroll up and down.
It also allows you to have customized actions like create new label at the bottom.
It also allows you to do filtering at the top with a simple search bar.
What is the simplest way to implement something like that and allow me to put in customized actions like the Create new label at the bottom?
At the barest minimum have a way to display all the checkboxes in a scrollable div or select element.
UPDATE:
Currently, I have only the following checkboxes
<div class="input select">
<label for="SiteSite">Sites</label>
<input type="hidden" name="data[Site][Site]" value="" id="SiteSite">
<div class="checkbox"><input type="checkbox" name="data[Site][Site][]" value="1" id="SiteSite1"><label for="SiteSite1">ODSite:P11379-440YishunAve11 HWSW_ESTA ENO21.000070.10001 92640145</label></div>
<div class="checkbox"><input type="checkbox" name="data[Site][Site][]" value="2" id="SiteSite2"><label for="SiteSite2">ODSite:P11374-SGRecClub HWSW_ESTA ENO21.000070.10002 92640147</label></div>
</div>
You can use a plugin called Select2, which has all the options you expect from a <SELECT> tag.
http://img594.imageshack.us/img594/543/select2.png
I have a Rails 3.2.8 application and I'm trying to customize some of the classes that come with the simple_form_for gem.
I have a page with many multiple select boxes on it, and to use space wisely I want the labels to appear on top of the select boxes.
I can't quite figure out how to do that. I have very little CSS experience and I'm trying to dive right in. I have used float with some success, but when you use simple_form_for you end up with a bunch of nested <div> tag for a form element. So my select box is only floating as far left as the containing <div> tag. I want it to be in line with the label. Here is a rendered example:
<div id="attribute_value_list" class="attribute_value_list">
<div class="control-group select required">
<label class="select required control-label" for="app_attribute1">
<abbr title="required">*</abbr>
Vehicle: Make
</label>
<div class="controls">
<select id="app_attribute1" class="select required select_attribute_value" size="10" name="app[attribute1]">
...
</select>
</div>
</div>
</div>
You will need to apply position:relative to the containing div (pick one that holds the label and the controls), and then position:absolute to the label, along with left and top to position it wherever you want - relative to the containing div.