XUpload - Only allow one choice checkbox at a time.

Posts: 21
Joined: Jan 08, 2007 10:35 pm

Only allow one choice checkbox at a time.

#1 Postby ap » Jan 18, 2007 9:54 pm

Is it possible to program the upload_form to only allow one selection in the checkboxes at a time? I have users who select two checkboxes; the system displays a generic window that says transfer complete. The user is not sure what happens and clicks again. Eventually, the file does get uploaded. Better if they are only allowed to make one selection at a time, if they choose the first one, then the others get blanked out, etc.

User avatar
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#2 Postby PilgrimX182 » Jan 19, 2007 6:55 am

Good idea man! Will use radiobuttons.

To allow only one progress bar mode choose one checkbox and add

Code: Select all

checked style="display: none;"
to the end of tag.

After that you can comment/romove other checkboxes.

Posts: 21
Joined: Jan 08, 2007 10:35 pm

#3 Postby ap » Jan 19, 2007 4:03 pm

Thanks, That worked if I only want one selected. However I need to give the users a choice and have them check only one and not both. Any quick fix ideas.

Posts: 21
Joined: Jan 08, 2007 10:35 pm

#4 Postby ap » Jan 19, 2007 4:30 pm

Hey, Just figured it out. Add the following to the upload_form.html script.

This first part gets placed before the </head> line.


<!-- Begin
function checkBoxValidate(cb) {
for (j = 0; j < 2; j++) {
if (eval("document.F1Upload.box[" + j + "].checked") == true) {
document.F1Upload.box[j].checked = false;
if (j == cb) {
document.F1Upload.box[j].checked = true;
// End -->

Replace your checkboxes with this for each checkbox...

<Input type="checkbox" name="popup" id="box" onClick="javascript:checkBoxValidate(0)">

<Input type="checkbox" name="inline" id="box" checked onClick="javascript:checkBoxValidate(1)">

I only have two check boxes. If you are using all three, add and change the last checkbox to <Input type="checkbox" name="inline" id="box" checked onClick="javascript:checkBoxValidate(3)">. Also, the scirpt you placed at the top should be changed to <3 and so on for as many checkboxes as you have.