Results 1 to 2 of 2

Thread: Help outputing value to textbox

  1. #1
    Join Date
    Apr 2009

    Help outputing value to textbox

    Hi I am creating a webpage that when a user clicks a textbox the number of checked ones appears in a read only text box I have got this to work. However, if 6 - 9 boxes are checked I want the word "bronze" to appear in another read only checkbox likewise if 10 - 12 are checked "silver" should appear in the same read only text box as bronze and if 13 - 15 boxes are checked "gold" appears in the read only checkbox a new function should be used.

    Code So Far.

    <script type="text/javascript">
    t = 0;
    function totals(thisCheckbox) {
    if (thisCheckbox.checked)
    t += parseFloat(thisCheckbox.value);
    } else {
    t -= parseFloat(thisCheckbox.value);
    document.getElementById("total").value = t;

    <FORM name="form1" id="form1">
    <input type="checkbox" name="cbox" value="1" onclick="totals(this);">
    (note: repeated 14 more times)

    <input type="text" readonly="readonly" name ="total" id="total">
    (where number of checkboxes checked is outputed)

    <input type="text" readonly="readonly" name="award" id="award">
    (where bronze, silver or gold is outputed depending on boxes checked)


  2. #2
    Join Date
    May 2006
    Odenton, MD
    use if/else if condition to verify the range in which fall the number. when a condition is met, write the word to textbox. what follow is a pseudo-code:
    if(greater or equal than 6 and less or equal than 9)write 'bronze';
    else if(>= 10 && <= 12)write 'silver';
    else if(...)write 'gold';
    else write empty string;
    my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous.
    my nature language is javascript, then come spanish and english -- me

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center