Good day,
I'm trying to simulate a click on a browse file element but I couldn't make it work.
I found this: http://www.randomsnippets.com/2008/03/05/simulate-a-button-click-via-javascript/
and tried and it works in 'button' and 'submit' types:
<input type="checkbox" onClick="document.getElementById('theSubmitButton').click();">Check the box to simulate a button click
<input type="submit" name="theSubmitButton" id="theSubmitButton" value="Button" onClick="alert('The button was clicked.');">
but when I tried to change it to 'file' type:
<input type="checkbox" onClick="document.getElementById('theSubmitButton').click();">Check the box to simulate a button click
<input type="file" name="theSubmitButton" id="theSubmitButton" value="Button" onClick="alert('The button was clicked.');">
It wouldn't work in Firefox and IE8. But the file browser window appears in Google Chrome.
Is there a problem with this approach? How could I make it work in FF and IE8?
Thank you very much!