I'm trying to change the standard checkboxes to a font-awsome version.
The problem is I can't change the HTML since it's generated and I can't use jQuery either.
Is there a way to "find" the label for my checkbox in the html below and change label:before on checkbox true or false?
EDIT: I think I might have been a bit unclear, the full code includes a javascript that makes it impossible for me to use javascript without changing it.
Also, the class for the labeltext is commonly used and can be -1 or -2 as well.
<table cellpadding="0" cellspacing="0" class="odincategory odincategory38 odincategory-even odincategory-placement2 odincategory-placement-even odincategory-multi" id="odincategory38-holder">
<tbody>
<tr>
<td class="odincategorycheckcolumn">
<input type="checkbox" name="odinanswer1" value="38" class="odincategorycheckmulti" id="odincategory38">
</td>
<td class="odincategorylabelcolumn">
<table cellpadding="0" cellspacing="0" id="odincategorylabel38">
<tbody>
<tr>
<td class="odincategorylabel">
<label for="odincategory38"><span class="odinfontnumber-0">Choice<br>
</span></label>
</td>
</tr>
</tbody>
</table>
</td>
<td class="odincategorymarkcolumn"></td>
</tr>
</tbody>
</table>
This cannot be done using pure CSS.
The problem is that you can only select adjacent, following or descending elements. In your case the label is somewhere else in the document tree.
If you could have the label next to the checkbox you could do something like
input[type=checkbox] + label {
color: green;
}
input[type=checkbox]:checked + label {
color: red;
}
But this does not work with your code.
Try this sample that change the color of the label...
In the same way you can change what you need.
In this example I used a button but you can write a special function that changes the font after page is loaded
<table cellpadding="0" cellspacing="0" class="odincategory odincategory38 odincategory-even odincategory-placement2 odincategory-placement-even odincategory-multi" id="odincategory38-holder">
<tbody>
<tr>
<td class="odincategorycheckcolumn">
<input type="checkbox" name="odinanswer1" value="38" class="odincategorycheckmulti" id="odincategory38">
</td>
<td class="odincategorylabelcolumn">
<table cellpadding="0" cellspacing="0" id="odincategorylabel38">
<tbody>
<tr>
<td class="odincategorylabel">
<label for="odincategory38" id="labelForodincategory38"><span class="odinfontnumber-0">Choice<br>
</span></label>
</td>
</tr>
</tbody>
</table>
</td>
<td class="odincategorymarkcolumn"></td>
</tr>
</tbody>
</table>
<input type="button" onclick="document.getElementById('labelForodincategory38').style.color='blue'" value="Click Me to Change Color" />
Related
I have the following html in one of my mails:
<center>
<table class="button">
<tbody>
<tr>
<td>
Set Now
</td>
</tr>
</tbody>
</table>
</center>
The problem is that on Gmail this Set Now button is properly centered but on Yahoo it is aligned to the left side. Here is picture that shows the problem:
Try following code :
<td align="center">
Set Now
</td>`
Nesting another <table> is safer than using <center>. This should cover all your bases:
<td style="text-align: center;">
<table class="button" align="center" style="margin: auto">
<tbody>
<tr>
<td>
Set Now
</td>
</tr>
</tbody>
</table>
</td>
Try with
<table class="button" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="100%" align="center">
Set Now
</td>
</tr>
</tbody>
Set margin-left and margin-right to auto to the parent table. Like this,
<table class="button" style="margin-left:auto;margin-right:auto;">
<tbody>
<tr>
<td>
Set Now
</td>
</tr>
</tbody>
Although I must say that only styling the anchor tag to be a button is not going to work across all email clients, you probably should use code generated from here https://buttons.cm/
I'm working on a form in my application and trying to clean up the code that was put in place before me. HEre's something I'm coming across that seems like bad practice and I am having a hard time trying to abbreviate it and clean it up.
Here's the code...
<tr>
<td style="padding-top: 10px; padding-bottom: 10px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="6%"></td> <---- I want to get rid of this!
<td width="45%">
<asp:CheckBox ID="chkBHRAExpiresDischarge" runat="server" onclick="RadioControl(this);" Text="Upon my discharge from treatment" />
</td>
<td>
<asp:CheckBox ID="chkBHRAExpiresReceiptOfInfo" runat="server" onclick="RadioControl(this);" Text="Upon receipt of the requested information" />
</td>
</tr>
<tr>
<td></td> <------- Have to keep adding this for every checkBox
<asp:Checkbox ID=.............."
</tr>
So what I'm trying to get rid of the the initial indentation, mainly ....
<td width="6%"></td>
Because this is in place, i have to do a
<td></td>
before every single row otherwise the indentation dissapears. Is there any way to fix this so that all my checkboxes are indented?
You can use colspan="2" on the checkbox cells and put padding-left: 6% as a style. Here's a JS fiddle. I added a row above your first row to show the column spacing, modified the first row use this change, and left the second row intact.
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td>One</td><td>Two</td><td>Three</td></tr>
<tr>
<td width="45%" colspan="2" style="padding-left: 6%">
<input type="checkbox" /><label>Checkbox</label>
</td>
<td>
<input type="checkbox" /><label>Checkbox</label>
</td>
</tr>
<tr>
<td width="6%"></td> <!---- I want to get rid of this! -->
<td width="45%">
<input type="checkbox" /><label>Checkbox</label>
</td>
<td>
<input type="checkbox" /><label>Checkbox</label>
</td>
</tr>
</table>
edit: Also, I recommend validating your HTML. You can wrap your code snippet up with a doctype and the other necessary items to get identify errors and warnings at https://validator.w3.org.
<!DOCTYPE html><html><head><title>Title is Required!</title></head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td>One</td><td>Two</td><td>Three</td></tr>
<tr>
<td width="45%" colspan="2" style="padding-left: 6%">
<input type="checkbox" /><label>Checkbox</label>
</td>
<td>
<input type="checkbox" /><label>Checkbox</label>
</td>
</tr>
<tr>
<td width="6%"></td> <!---- I want to get rid of this! -->
<td width="45%">
<input type="checkbox" /><label>Checkbox</label>
</td>
<td>
<input type="checkbox" /><label>Checkbox</label>
</td>
</tr>
</table>
</body><html>
Not sure if you'll find this acceptable, but you could keep the <td width="6%"></td> and give it a huge rowspan value. So like this:
<td width="6%" rowspan="999999"></td>
Then you can omit the empty <td></td> for the first 999999 rows. Most likely you have fewer rows than that; or if not, just make the rowspan even higher. The table will not become longer just because of the huge rowspan value.
Of course this all breaks down if you also have rows where the indent should not be applied; a fix for that could be to calculate the exact rowspan value in advance.
I had a hard time creating a title for this one!
Below is the example HTML that I'm parsing - truncated in parts for brevity, but hopefully enough for someone to understand what I'm looking for.
I'm looking to identify the INPUT at the very bottom of the example code.
I cannot use the ID because it constantly changes. i.e. id="id_mstr111_txt"
Let me describe in english, as best as I can, what I'm trying to get at:
find the INPUT
...under a DIV with class="mstrPromptQuestion" that has as a descendant
...... span class="mstrPromptQuestionTitleBarTitle">Abstracted Period
Or written another way:
Given a DIV with class="mstrPromptQuestion" that contains a deeply embedded child node: span class="mstrPromptQuestionTitleBarTitle">Abstracted Period
find the INPUT (without using the ID because the numbers change with every build)
I'm not sure if this is even possible with XPath 2.0 and no jquery - just BASIC xpath functions.
<div id="id_mstr85" **class="mstrPromptQuestion"** style="display: block;">
<span class="mstrPromptQuestionRequired">
<div class="mstrPromptQuestionTitleBar">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="middle" align="left">
<span class="mstrPromptQuestionTitleBarIndex" style="display: inline;">2.</span>
<span **class="mstrPromptQuestionTitleBarTitle">Abstracted Period**</span>
<span class="mstrPromptQuestionTitleBarRequired" title="(Required)">(Required)</span>
</td>
</tr>
</tbody>
</table>
</div>
<table class="mstrPromptQuestionInfoTable" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="mstrPromptQuestionInfoCellLeft">
<td class="mstrPromptQuestionInfoCellRight">
</td>
</td>
</tr>
</tbody>
</table>
<div class="mstrPromptQuestionContents">
<table class="mstrPromptQuestionSimpleAnswerViewTitle" style="display: none;" cellspacing="0" cellpadding="0">
<div class="mstrPromptQuestionSimpleAnswerView" style="padding-left: 0px;" onmousedown="this.previousSibling.rows[0].cells[0].childNodes[0].checked = true; mstr.behaviors.PromptQuestion.onClickRadio('id_mstr85', false)">
<table id="id_mstr89" class="mstrListCart" style="display: table;" cellspacing="0" cellpadding="0">
<colgroup>
<tbody>
<tr>
<td class="mstrListCartCellAvailableHeader">
<table class="mstrListCartTablePathView" cellspacing="0" cellpadding="0">
<div id="id_mstr108" class="mstrSearchField" title=" style=" display: block;="">
<table class="mstrSearchFieldTable" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="mstrSearchFieldSearchBox">
<div id="id_mstr111" class="mstrTextBoxWithIcon" title=" style=" display: block;="">
<div class="mstrTextBoxWithIconCaption">
<table class="mstrTextBoxWithIconTable" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="mstrTextBoxWithIconCellInput">
<div><**input** id="id_mstr111_txt" maxlength="" onclick="if (mstr.utils.ISW3C) {this.focus();}" onkeypress="return mstr.behaviors.TextBoxWithIcon.onkeypress(arguments[0], self, 'id_mstr111', this.value)" name="id_mstr111_txt"
style="background-color: rgb(255, 255, 255);" size="" type="text" /></div>
</td>
For described in english:
//div[#class='mstrPromptQuestion'][.//span[#class='mstrPromptQuestionTitleBarTitle']]//input[contains(#id, '_txt')]
Written another way is the same, only that you specify to not use the id.
Identify a unique parent based on an attribute or based on a child and continue from there.
For above xpath you can also add a text constraint to the span like
[contains(text(), 'Abstracted Period')]
resulting in something like:
//div[#class='mstrPromptQuestion'][.//span[#class='mstrPromptQuestionTitleBarTitle'][contains(text(), 'Abstracted Period')]]//input[contains(#id, '_txt')]
If you're sure it's the last input in the div, you could do something like:
(//div[#class='mstrPromptQuestion']//input)[last()]
or something like:
(//div[#class='mstrPromptQuestion' and .//span[#class='mstrPromptQuestionTitleBarTitle']='Abstracted Period']//input)[last()]
if mstrPromptQuestionTitleBarTitle is important.
I have a CSS coding challenge for everyone here...
I have searched google and looked at multiple options, but cannot figure this one out.
Is also worth mentioning that I'm not a developer, but I understand the basics of how to implement CSS.
I have a section of code that contains check boxes,
I need to make only specific checkbox items bold (not all of the items) via CSS...
Under normal circumstances, the CSS code for this would be: font-weight: bold;
in the right class or ID, however, in my case, I'm using a third party platform with predefined, css classes for each of the code sessions, in the case of the checkboxes section, the CSS class for this is called: .formFieldLabel
So the CSS code section would like so:
.formFieldLabel {
padding-bottom: 2px;
}
Below is the html code section for the checkboxes:
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div class="" style="overflow: hidden">
<table cellspacing="0" cellpadding="1" class="">
<tbody>
<tr>
<td width="20" align="left">
<input type="checkbox" name="Field 1" id="form_0006_fld_2-0" value="First Choice">
</td>
<td width="*" align="left" style="padding-top: 3px; padding-right: 10px">
<label for="form_0006_fld_2-0" class="formFieldLabel">First Choice</label>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td>
<div class="" style="overflow: hidden">
<table cellspacing="0" cellpadding="1" class="">
<tbody>
<tr>
<td width="20" align="left">
<input type="checkbox" name="Field 1" id="form_0006_fld_2-1" value="Second Choice">
</td>
<td width="*" align="left" style="padding-top: 3px; padding-right: 10px">
<label for="form_0006_fld_2-1" class="formFieldLabel">Second Choice</label>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td>
<div class="" style="overflow: hidden">
<table cellspacing="0" cellpadding="1" class="">
<tbody>
<tr>
<td width="20" align="left">
<input type="checkbox" name="Field 1" id="form_0006_fld_2-2" value="Third Choice">
</td>
<td width="*" align="left" style="padding-top: 3px; padding-right: 10px">
<label for="form_0006_fld_2-2" class="formFieldLabel">Third Choice</label>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
Resuming, the CSS code to make such item bold will need to go inside the following CSS code section:
.formFieldLabel {
padding-bottom: 2px;
}
Can anyone please help me implement this solution?
You could use :nth-child() selector in css to select the checkbox you want.
So maybe something like this to select the second checkbox:
tr:nth-child(2) table input { }
Not sure it the above css works but, you can use :nth-child() to select the <tr> you want from the parent table then from there you can select the input box in the child table.
You can use attribute selectors like this.
<style>
.formFieldLabel[for=form_0006_fld_2-0] {
font-weight: bold;
}
</style>
But you have to know the id of checkbox to do this.
or just add a second css class
class="formFieldLabel boldLabel"
I'm using twitter-bootstrap and I have two tables like this: http://jsfiddle.net/MELUd/
<table class="table table-bordered">
<thead>
<tr>
<td colspan="2"><input type="text" ></td>
<td colspan="2"><input type="text" ></td>
<td colspan="2"><input type="text" ></td>
<td colspan="2"><input type="text" ></td>
<td colspan="2"><input type="text" ></td>
</tr>
</thead>
<tbody>
<tr>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
<td >XS</td>
</tr>
</tbody>
</table>
The text inputs of the first table does not resizing so the table isn't responsive.
But in the second table example works perfectly with simple text.
How I can make the input text with dynamic width so I'll not see the horizontal scrollbar?
Any help, tip or advice will be appreciated, and if you need more information let me know and i'll edit the post.
I think the way to do it is to use javascript to change the width dynamically.
$(document).ready(function(){
$('input').each(function(){
$(this).width($(this).parent().width()-20);
});
});
Check out the fiddle
Please adjust your padding and margin accordingly to center the inputs.
Another solution is to display inputs as blocks
.table input{
display:block;
width:80%;
margin-left:auto;
margin-right:auto;
}
Check out the fiddle
you could either try specifying a max-width to the textboxes, either in px or em.
input[type='text']{max-width:4em}
I'd say go with em.