Multi-Total Radio Button select

Results 1 to 2 of 2

Thread: Multi-Total Radio Button select

  1. #1
    Join Date
    Dec 1969

    Default Multi-Total Radio Button select

    An order form which utilizes checkboxes AND radio buttons for making a selection. The checkbox only allows one quantity of any item to be ordered, while the radio button only allows for one item within a defined group to be ordered.<BR><BR>How can I make it read MORE THAN ONE RADIO BUTTON?<BR><BR>function CheckChoice(whichbox)<BR> {<BR> with (whichbox.form)<BR> {<BR> //Handle differently, depending on type of input box.<BR> if (whichbox.type == "radio")<BR> {<BR> //First, back out the prior radio selection&#039;s price from the total:<BR> hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio.value);<BR> //Then, save the current radio selection&#039;s price:<BR> hiddenpriorradio.value = eval(whichbox.price);<BR> //Now, apply the current radio selection&#039;s price to the total:<BR> hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);<BR> }<BR> else<BR> {<BR> //If box was checked, accumulate the checkbox value as the form total,<BR> //Otherwise, reduce the form total by the checkbox value:<BR> if (whichbox.checked == false)<BR> { hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }<BR> else { hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }<BR> }<BR><BR> //Ensure the total never goes negative (some browsers allow radiobutton to be deselected):<BR> if (hiddentotal.value &#060; 0)<BR> {<BR> InitForm();<BR> }<BR><BR> //Now, return with formatted total:<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default I can't make sense of it...

    What are all those eval( )&#039;s in there for?<BR><BR>I can&#039;t see any reason for them. Are you just doing that to get numbers? If so, you should be using parseFloat, instead, I would think.<BR><BR>If only one radio button can be pushed at a time, then why do you care about reading the values from multiple radio buttons?<BR><BR>And if whichbox is a field in a form (it seems to be, since you do "with whichbox.form"), then what the heck is <BR> whichbox.price<BR>??? did you mean to code <BR> whichbox.value<BR>???<BR><BR>And I hope you realize that this code will only work in MSIE browsers. You can&#039;t use &#060;radioname&#062;.value (or &#060;selectname&#062;.value) in other browsers.<BR><BR><BR>

Posting Permissions

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