Note that there are some explanatory texts on larger screens.

plurals
  1. POform submit only running Javascript function for a second
    primarykey
    data
    text
    <p>I have two forms here, the first is a select dropdown select, which when posted generates another form, creating an amount input boxes based on the number selected. This second form then puts the data from the input boxes into 2 array. All this works perfectly but I am trying to add extra functionality to the submit button on the second form. I created a function 'showcontet()' to show and hide the content in the div with id 'table'. This works perfectly when used on a button outside of the form. When used on the submit button inside the form you can see the content for about 1 second before it then disappears again.</p> <pre><code> &lt;head&gt; &lt;script type="text/javascript"&gt; showcontent = function(){ var content = document.getElementById('tabl'); content.style.display = 'inline'; } &lt;/script&gt; &lt;?php $userkey = array(); $userval = array(); $usernum = $_POST['usernum']; $total = 0; ?&gt; &lt;form action='MYPIE.PHP' method='POST'&gt; HOW MANY SECTIONS? &lt;select name="usernum" value="&lt;?php echo $usernum;?&gt;"&gt; &lt;option&gt;1&lt;/option&gt; &lt;option&gt;2&lt;/option&gt; &lt;option&gt;3&lt;/option&gt; &lt;option&gt;4&lt;/option&gt; &lt;option&gt;5&lt;/option&gt; &lt;option&gt;6&lt;/option&gt; &lt;option&gt;7&lt;/option&gt; &lt;option&gt;8&lt;/option&gt; &lt;option&gt;9&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" name="submitnum" value="submit selection" /&gt; &lt;/form&gt; &lt;form action='MYPIE.PHP' method='POST'&gt; &lt;?php for ($i=1; $i&lt;$usernum+1; $i++){ echo '&lt;input type="hidden" value="' .$usernum.'" name="usernum" /&gt;'; echo "&lt;br&gt;insert key: &lt;input name='key".$i."' value='".$userkey[$i]."'&gt; insert value: &lt;input name='val".$i."' &gt;"; $userkey[$i] = $_POST["key".$i]; $userval[$i] = $_POST["val".$i]; } ?&gt; &lt;/br&gt; &lt;input type="submit" value="submit" name="submit keys" onclick="showcontent()" /&gt; &lt;/form&gt; &lt;/table&gt; &lt;div id="tabl" style="display:none;"&gt; content &lt;/div&gt; </code></pre> <p>Apologies for the bad indentation, I am pretty new to this &amp; thanks for any help</p>
    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.
 

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