Adding to checkbox - javascript?

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Adding to checkbox - javascript?

    I have a product that can have 1 extra option
    I want to be able to

    Check boxes in form

    O $20 for regular product
    O Add $5 option (adds to $20 reg product price)

    What's the best way to deal with this and what javascript would work for this?

    LArtJunky Guest

  2. Similar Questions and Discussions

    1. Dynamic function or javascript to change checkbox tounchecked?
      I am wondering if there is a ColdFusion function or maybe some simple javascript that can help me. I want to dynamically change a checkbox from...
    2. Adding a Blank Page with JavaScript
      I'm being trying to add a blank page to an existing PDF document using JavaScript on Adobe Acrobat 5.0, unsuccessfully. I can insert a new...
    3. Find what checkbox is checked in javascript
      I have to sets of checkboxes. The second is to delete the row. So when I click that checkbox I want to add it to an array. I also need to take it...
    4. adding multiple checkbox data to database
      ok im new to this and have tried using a while loop adn a for loop to do it but cant get it to work, here is what i have, a registration page for...
    5. adding a checkbox to select the row.
      i'm using c#. code behind if possible. i need a simple way to put a checkbox column in my datagrid and a button to see witch rows are selected......
  3. #2

    Default Re: Adding to checkbox - javascript?

    Anyone?
    LArtJunky Guest

  4. #3

    Default Re: Adding to checkbox - javascript?

    LArtJunky wrote:
    > I have a product that can have 1 extra option
    > I want to be able to
    >
    > Check boxes in form
    >
    > O $20 for regular product
    > O Add $5 option (adds to $20 reg product price)
    >
    > What's the best way to deal with this and what javascript would work for this?
    add an onClick handler for each checkbox:

    <INPUT name='regular' type='checkbox' onClick='calcTotal(this.checked,
    this.value)' value=20>
    <INPUT name='option' type='checkbox' onClick='calcTotal(this.checked,
    this.value)' value=5>

    i assume you have a TOTAL field so, define a function to update it
    anytime a user select/unselect an option:

    <SCRIPT>
    function calcTotal(cbStatus, idx) {
    str = document.yourForm.totalField.value;
    totalVar = parseFloat(str);
    idxn = parseInt(idx, 10);
    if (cbStatus) {
    totalVar = totalVar + idxn;
    } else {
    totalVar = totalVar - idxn;
    }
    document.yourForm.totalField.value = totalVar.toString();
    }
    </SCRIPT>

    not tested, post again if you hace any problem

    hth,

    jdoe
    John Doe Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139