I'm having problem with placeholders.
I want to ask, is there possibility to style value in input fields but in the way to style words of that value different.
For example, if we have input field which have initial value "First Name" i want to have green color for "First", and red color for "Name" (this is just an example).
Is this even possible?
Note: Im using value as "placeholder" (instead of placeholder html attribute) because of ie.
<input type="text" value="First Name" onFocus="if (this.value == 'First Name') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'First Name';}" />
unfortunately its not possible. when it comes to styling the form elements, there are many hindrances, color can be set to for an element not chracters, try this:
http://jsfiddle.net/Fgd2e/1/
You may change the color of an input using the color style attribute. Having separate colors for each word is much harder. You need to have an overlay that displays the right colors. Besides, the cursor would disappear, so that the user wouldn't know where he currently is.
Related
In the code sample below I have a simple form with two submit buttons.
<form>
<input type="submit" value="< Previous">
<input type="submit" value="Next >">
</form>
Depending on the value attribute the buttons will get different sizes, like the image below:
Is there a method I can use to make the buttons equally sized based on the widest button? I use Bootstrap if that's any advantage...
I know that I could use a fix CSS-width (or similar) to set equal widths on the buttons. But since I don't know how wide the value will be in advance it won't solve the problem... (or will it?).
Use JQuery
var prev = $('#prev').width();
var next = $('#next').width();
if (prev > next) {
$('#next').width(prev);
} else {
$('#prev').width(next);
}
Here is a jsfiddle I made..
Within a series of check boxes (lets say 3 options) I am looking to target a specific input element on the checking/unchecking of the associated label.
HAML
.choice-select-button
= check_box_tag("order[recipes][]", recipe.id, selected)
= label_tag do
= t(".step_4.tick_box_to_select")
Renders HTML
<div class="choice-select-button">
<input type="checkbox" name="order[recipes][]" id="order_recipes_" value="6" checked="checked">
<label>Click to select</label>
</div>
Each <input> is assigned same id, namely id="order_recipes_" so if I give set <label for="order_recipes_"> and the user then 'un-checks' the label then only the first input on the page with the id="order_recipes_" is styled according to my css instructions.
The only differentiator I can see for the choice-select-button.input is it's value. As such I was looking at giving the label a for= that targets inputs with the id="order_recipes_ AND value="6". First up, is this doable, and secondly, is the best way to do something like this or is there a much more simple method?
Thanks in advance.
According to the rrails doc:
check_box_tag(name, value = "1", checked = false, options = {}) Link
Creates a check box form input tag.
Options
:disabled - If set to true, the user will not be able to use this
input.
Any other key creates standard HTML options for the tag.
you can generate different ids like this:
check_box_tag("order[recipes][]", recipe.id, selected, {id: recipe.id})
I have a form, which has a text area. I want to be able to set the text color of the text inside of the text area when they click the color intended.
So far, I have it to where when they click the color, it sets the hex color inside of a hiddenfield. How could I go about changing the textcolor with css based on the hiddenfield results.
I don't think I can alter the CSS with the GET/POST method, because I want the color to change immediately, not only when the form is posted. Is there a way to do this with either javascript or PHP?
I use the setting of the color to the hiddenfield using (through the img src):
onclick="document.getElementById('color').value = '#ffffff'; " />
HERE IS A JSFIDDLE OF WHAT I HAVE SO FAR:
jsfiddle.net/ymG6t
Ok I figured it out! Instead of using
onclick="document.getElementById('color').value = '#ffffff'; " />
I used: onclick="document.getElementById('color').style.color = '#ffffff';" />
onto the field itself. No need for the hiddenfield!
I have a solution. copy and paste code below:
<script>
function change_color(col){
if ( col == 'red'){
document.getElementById("text").style.color = '#f00';
}
if ( col == 'green'){
document.getElementById("text").style.color = '#0f0';
}
if ( col == 'blue'){
document.getElementById("text").style.color = '#00f';
}
}
</script>
<form>
<input type='radio' onchange="change_color(this.value)" name='color' value='red' >Red<br>
<input type='radio' onchange="change_color(this.value)" name='color' value='green' >Green<br>
<input type='radio' onchange="change_color(this.value)" name='color' value='blue' >Blue<br>
Text:<textarea id='text'>Here is the text that you want to change it's color</textarea>
</form>
Save into a new file with *.php extension.
If you want to save it as html, you must add html tag for header, body and other such as <html> in the beginning, <head>, and then <body>, and of course with it's close tag.
use it as a reference, you can modify the code/script as you need.
may it help! :D
I've been tryin to find an example of the syntax for getting an html 'title' for a string when using Html.Encode(). I want to display the full name in the mouseover title, if it's too long.
Is there a way to do this without wrapping the string in a < span >, i.e.
<span title = "<%=Html.Encode(model.Name) %>"> //displays the full name on mouseover
<%=Html.Encode(model.Name.Substring(0, 10))%>... //displays the name up to a max length
</span>
Or should I just do it this way?
Thanks!
Without a containing element, where are you going to hang your title?
So, yes, you should wrap it in an inline element like span
For example currently, the value is set with lblAmount.Text = Amount & " €"
How can i add (dynamically) superscript to the € sign?
use the SUP tag.
lblAmount.Text = Amount & "<sup>€</sup>"
You do this best by adding either a style attribute or by adding a class (and adding the style in a style tag or a css file.
<asp:Label id="lblAmount" runat="server"></asp:Label><asp:Label id="lblAmountSymbol" runat="server" CssClass="yourclass"></asp:Label>
span.yourclass {
font-size:9px;
vertical-align:top;
}
or
<asp:Label id="lblAmount" runat="server"></asp:Label><asp:Label id="lblAmountSymbol" runat="server"></asp:Label>
and this, in your code file
Me. lblAmount.Style.Add(HtmlTextWriterStyle.FontSize, "9px")
Me. lblAmount.Style.Add(HtmlTextWriterStyle.VerticalAlign, "top")
You could also use the html equivalent sup:
Me. lblAmount.Text = Amount & " <sup>€</sup>"
Goto Start->Programs->Accessories->System tools->Character Map
Now select this Character ² from the Characters listed.
Click Select
Click Copy
Then try to change the text of any control by pasting this Character in the Lable or Button Caption at Properties.
Even you can wrting code also like this:
Code\Button1.Text = "mm ²"\Code
This is working fine with me.