View Full Version : can i retun the value of chck boxes in a hidden input?

04-03-2003, 06:10 AM
Is it possialbe to use 20 checkboxes (1 to 20) and 10 radio bottons (1 to 10) to generate the value for "item_name" for a Single Item Purchase with PayPal when they use (<input type="hidden" name="item_name" value="">)? I want to click on 5 of the 20 checkboxes and 1 radio button and send the value in the (<input type="hidden" name="item_name" value="">). I am useing javascript to limt the to five choices
<script language="javascript">

function KeepCount() {
var NewCount = 0
if (document.item1.A.checked)
{NewCount = NewCount + 1}
if (document.item1.B.checked)
{NewCount = NewCount + 1}
if (document.item1.C.checked)
{NewCount = NewCount + 1}
if (document.item1.D.checked)
{NewCount = NewCount + 1}.....
witch workes well. I use a plain radio button<input type="radio" name="item2" value="1">. I want to add the value if item1(witch should be five letters) and the radio button selection and send that as a value for the (<input type="hidden" name="item_name" value="">) Can this be done or am I crazy???? Any help would be wounderful.:o

04-05-2003, 08:46 AM
this should work...im stillworking on some added functionality but this should be good enough for a while:

[EDIT: lol, this is quite a project...loop da loop!!...i'll update this as i make it better]

<script type="text/jav&#97;script">

msg = Object;
msg['item1'] = "Please select 5 checkbox options"

function getValues(f){
var plHolder,i=0,j,cnt, newItem='';

if(plHolder.type=='checkbox' || plHolder.type=='radio'){
var j = 0;
newItem = newItem + plHolder;


var len = newItem.length

if(len != 6){
alert(msg['item1'] + "\nYou have selected " + (len - 1));
return false;
} else {
return true;

<form name="frmChk">

Please select 5 items from Group One and 1 item from Group Two
<strong>Group One</strong>
<INPUT type="checkbox" name="item1" value="A" />A
<INPUT type="checkbox" name="item1" value="B" />B
<INPUT type="checkbox" name="item1" value="C" />C
<INPUT type="checkbox" name="item1" value="D" />D
<INPUT type="checkbox" name="item1" value="E" />E
<br />
<INPUT type="checkbox" name="item1" value="F" />F
<INPUT type="checkbox" name="item1" value="G" />G
<INPUT type="checkbox" name="item1" value="H" />H
<INPUT type="checkbox" name="item1" value="I" />I
<INPUT type="checkbox" name="item1" value="J" />J
<br />
<INPUT type="checkbox" name="item1" value="K" />K
<INPUT type="checkbox" name="item1" value="L" />L
<INPUT type="checkbox" name="item1" value="M" />M
<INPUT type="checkbox" name="item1" value="N" />N
<INPUT type="checkbox" name="item1" value="O" />O
<br />
<INPUT type="checkbox" name="item1" value="P" />P
<INPUT type="checkbox" name="item1" value="Q" />Q
<INPUT type="checkbox" name="item1" value="R" />R
<INPUT type="checkbox" name="item1" value="S" />S
<INPUT type="checkbox" name="item1" value="T" />T
<br />
<strong>Group Two</strong>
<INPUT type="radio" name="item2" value="1" checked="checked" />1
<INPUT type="radio" name="item2" value="2" />2
<INPUT type="radio" name="item2" value="3" />3
<INPUT type="radio" name="item2" value="4" />4
<INPUT type="radio" name="item2" value="5" />5

<form name="frmSub" action="jav&#97;script: alert('Success!' + '\nHidden Value = ' + document.frmSub.item_name.value)" method="post" onsubmit="return getValues(this)"
<input type="hidden" name="item_name" value=""/>
<input type="submit" value="Submit" />
<input type="reset" value="reset" />



Change the form action to your own. Comments on improvement are more than welcome.