views:

90

answers:

1

I have a checkbox and a file upload element, they both are dependent on each other such that if on is on that other has to be off(empty in case of file upload field) for this i have used the javascript on onclick of checkbox and onchange of file upload..

For onchange event the checkbox gets deselected in all browsers

but after i select any file using file upload element and then i click on the check box then the file upload element does not gets empty in IE, but works fine in FF

the javascript used in onclick on checkbox is as follows:

function yousend_it()
{
  if(document.getElementById('yousendit').checked)
  {

   document.getElementById('bgimage').value = "";
   window.open('https://www.yousendit.com/dropbox?dropbox=mydomain','_blank');
   //return false;
  }
  return true;
}

Could someone tell me how can i make it work in all browser perfectly?

+2  A: 

For security reasons you cannot set the value of the upload field using JS. Apparently FF at least lets you change it to nothing.

A better way to make the two elements "depend" on each other is to disable the upload field unless the checkbox is checked.

slosd
+1 Thats the good Idea How can I do that!!!
OM The Eternity
document.getElementById('bgimage').disabled = true;
slosd