Note that there are some explanatory texts on larger screens.

plurals
  1. POupload button is triggering function it should not trigger
    primarykey
    data
    text
    <p>Internet Explorer is giving me big problems with an upload button I have associated with a file input.</p> <p>Below is the function where it handles a normal submit button:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { myClickHandler=function(e){ if (!validation()) return false; if (!confirm("Are you sure you want to Proceed?" + "\n" )) return false; return true; }; $('#QandA').submit(myClickHandler); }); &lt;/script&gt; </code></pre> <p>Below I am showing how the imageuploadform is appended into a table which is in the <code>#QandA</code> form:</p> <p>jquery:</p> <pre><code>function insertQuestion(form) { var $image = $("&lt;td class='image'&gt;&lt;/td&gt;"); var $fileImage = $("&lt;form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target_image' onsubmit='return imageClickHandler(this);' class='imageuploadform' &gt;" + "Image File: &lt;input name='fileImage' type='file' class='fileImage' /&gt;&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;&lt;label class='imagelbl'&gt;" + "&lt;input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /&gt;&lt;/label&gt;&lt;/form&gt;"); $image.append($fileImage); $tr.append($image); } </code></pre> <p>HTML (#QandA form):</p> <pre><code> &lt;form id="QandA" action="&lt;?php echo htmlentities($action); ?&gt;" method="post"&gt; //Below is button where when clicked, it will append the image upload form into the table &lt;table id="questionBtn" align="center"&gt; &lt;tr&gt; &lt;th&gt; &lt;input id="addQuestionBtn" name="addQuestion" type="button" value="Add Question" onClick="insertQuestion(this.form)" /&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; //image upload form is appended into table below: &lt;table id="qandatbl" align="center" cellpadding="0" cellspacing="0" border="0"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="image"&gt;Image&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;/table&gt; &lt;div id="qandatbl_onthefly_container"&gt; &lt;table id="qandatbl_onthefly" align="center" cellpadding="0" cellspacing="0" border="0"&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;&lt;input id="submitBtn" name="submitDetails" type="submit" value="Submit Details" /&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p>As mentioned the image upload form is appended into the <code>#QandA</code> from and I believe because of this it is causing the problem of the <code>myClickHandler=function(e)</code> being triggered when the "Upload" button is clicked on even though it should not trigger that function at all. Only the "Submit Details" button in the top form should trigger the <code>myClickHandler()</code> function.</p> <p>So my question is possibly what do I need to change in order for only the <code>Submit Details</code> button to trigger the <code>myClickHandler()</code> function?</p> <p>UPDATE:</p> <pre><code>var $video = $("&lt;td class='video'&gt;&lt;/td&gt;"); var $fileVideo = $("&lt;form action='videoupload.php' method='post' enctype='multipart/form-data' target='upload_target_video' onsubmit='return videoClickHandler(this);' class='videouploadform' &gt;" + "Video File: &lt;input name='fileVideo' type='file' class='fileVideo' /&gt;&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;&lt;label class='videolbl'&gt;" + "&lt;input type='submit' name='submitVideoBtn' class='sbtnvideo' value='Upload' /&gt;&lt;/label&gt;&lt;/form&gt;"); $video.append($fileVideo); $tr.append($video); var $audio = $("&lt;td class='audio'&gt;&lt;/td&gt;"); var $fileAudio = $("&lt;form action='audioupload.php' method='post' enctype='multipart/form-data' target='upload_target_audio' onsubmit='return audioClickHandler(this);' class='audiouploadform' &gt;" + "Audio File: &lt;input name='fileAudio' type='file' class='fileAudio' /&gt;&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;&lt;label class='audiolbl'&gt;" + "&lt;input type='submit' name='submitAudioBtn' class='sbtnaudio' value='Upload' /&gt;&lt;/label&gt;&lt;/form&gt;"); $audio.append($fileAudio); $tr.append($audio); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload