javascript - If condition is true print text in input field with specific ID -



javascript - If condition is true print text in input field with specific ID -

noob in need of input here. i've spent hours trying work, both php , javascript , i'm @ now.

i want input field show specific text based on condition. if digit in input field 'ebctotal' within range 1-4, show text "very pale" in input field 'hue'.

code:

function gethue() { var ebc = document.getelementbyid("ebctotal").value; if (ebc >= 1 && ebc <= 4) { // insert text "very pale" element id 'hue' document.getelementbyid('hue').value; } }

html:

// print text in field <input class="input" type="text" id="hue" size="7" maxlength="20"> // based on value of field <input class="input" type="text" id="ebctotal" size="7" maxlength="20">

am on right track?

cheers

if want check whether length of "ebc" between 1-4 seek like;

function gethue() { var ebc = document.getelementbyid("ebctotal").value; if (ebc.length>=1 && ebc.length<=4) { document.getelementbyid('hue').value='very pale'; } }

or whether value of "ebc" between 1-4 seek like;

function gethue() { var ebc = parseint(document.getelementbyid("ebctotal").value); if (ebc>=1 && ebc<=4) { document.getelementbyid('hue').value='very pale'; } }

javascript if-statement

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -