开发者

Checkbox onclick javascript do not make the file upload element empty in IE

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 o开发者_Go百科f 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜