How to convert html tags to normal content display? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:08:07
Original
1126 people have browsed it

I need to dynamically control the value of the input. If I give a value like -1,600,000, which attribute of the input should be assigned a value in js How can he normally display a #ff0000 of 1,600,000?


Reply to discussion (solution)

style="color:#ff000"

Thank you upstairs, but my intention was not to Write it to death, only when it is judged to be a negative number in js, you can use js to give it a value and display it in red. When it is a positive number, you do not need to use red, and use element.value = 123 like this.

Then when js determines that it is a negative number, use js to set the color='#ff0000' of the style of the text box

First, you get the value passed into the input value. Whether it is a negative value, you can use regular expressions! If it is a negative value, when it returns true, set the style for the current input box you need to set, that is, the value of the color you mentioned

(var formatResult = formatDecimal(unformatNumber(orderNominal) - unformatNumber(totalExecNominal),null,null,0,null));  getElement("total_amount").xxx = formatResult ;
Copy after login


If the formatDecimal result is positive The return result of the number is 1,600,000. If it is a negative number, the format result is returned as -1,600,000. So how can I use this return result correctly to make it display red?

(var formatResult = formatDecimal(unformatNumber(orderNominal) - unformatNumber(totalExecNominal),null,null,0,null));
if (isNaN(formatResult)) {
getElement("total_amount ").value = -formatDecimal(unformatNumber(-orderNominal) - unformatNumber(-totalExecNominal),null,null,0,null));
getElement("total_amount").style.color = '#ff0000';
} else {
getElement("total_amount").value = formatResult;
}


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template