solidcodes — 2013-06-02T20:53:57-04:00 — #1
I have codes below,
<div id="uploadBox" class="well" onClick="$('#photoimg').click();">
<button class="btn btn-mini btn-primary" type="button">Upload File</button>
<input type="file" class="hide" name="photoimg" id="photoimg" onchange="$(this.form).submit();"/>
Just wondering what these codes mean,
Okay let me guess, when I click the button, it will invoke the <input type="file" ...> and auto submit the form with the codes,
Am I right or am I wrong?
Thanks in advanced.
pullo — 2013-06-03T02:28:27-04:00 — #2
You are right.
is shorthand for:
which will execute all handlers and behaviours attached to the matched element.
I'm not sure why you would want to do this, though.
First off, in-line event handlers are usually a bad thing, as they impact negatively on the readability and maintenance of your mark-up.
Secondly, wouldn't it be less confusing to have a "Select File" button and a "Submit" button?
Hope that helps.
solidcodes — 2013-06-03T05:36:55-04:00 — #3
pullo — 2013-06-03T06:12:42-04:00 — #4
Ah, ok. With a bit more context it makes more sense.
I still stand by what I said about in-line event handlers, though.