Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmitting form issues: TypeError: this.form is null
    text
    copied!<p>I have a php page that displays all of the service logs for a given site in a table.</p> <p>At the end of the table I have a new row that has an "Add new service log" button.</p> <p>Clicking the button hides that row and displays a new row with a form and the desired inputs as well as a new row with buttons "Save" and "Cancel". </p> <p>The "Save" button calls a Javascript function that checks that the key input has been filled out. When hitting "Save", I see in the console log </p> <blockquote> <p>TypeError: this.form is null</p> </blockquote> <p>Here is my code:</p> <pre><code> // SQL Query // Table data of queried results // Add a new service log echo "&lt;tr id='AddNew'&gt; &lt;td&gt;&lt;input type=button value='Add New' onclick=\"$('#AddNew').hide();$('#AddNewHid').show();$('#SaveCancel').show();\"&gt;&lt;/td&gt; &lt;td colspan=12&gt; &amp;nbsp &lt;/td&gt;&lt;/tr&gt; &lt;form name='AddNewLog' method='POST' action='servicelook.php' id='AddNewService'&gt; &lt;tr style='display: none;' id='AddNewHid'&gt; &lt;td&gt;&lt;input type='text' value='$lastID' name='ticketid' size=10&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='$siteID' name='SiteID' size=4&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='$siteName' name='SiteName' size=20&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='$userid' name='takenBy' size=4&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='$now' name='callTime' size=20&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='' name='caller' size=20&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='' name='callPhone' size=14&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name='issue' value = '' rows=3 cols=10&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name='fix' value = '' rows=3 cols=10&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='$userid' name='solvedBy' size=4&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' value='$now' name='solvedTime' size=20&gt;&lt;/td&gt; &lt;td style='min-width:100px;max-width:100px;'&gt;&lt;input type='checkbox' name='fup' value='fup'&gt;Follow Up&lt;/td&gt;&lt;/tr&gt; &lt;input type='hidden' value='Yes' name='AddNew'&gt; &lt;input type='hidden' value='$userid' name='userid'&gt; &lt;input type='hidden' value='$session' name='session'&gt; &lt;input type='hidden' value='$siteid' name='siteid'&gt; &lt;tr style='display: none;' id='SaveCancel'&gt; &lt;td colspan=2&gt; &lt;input name='save' type='button' onclick='inputCheck(this.form.issue);' value='Save'&gt; &amp;nbsp &lt;input type='button' value='Cancel' onclick=\"$('#AddNew').show();$('#AddNewHid').hide();$('#SaveCancel').hide();\"&gt;&lt;/td&gt; &lt;td colspan=11&gt; &amp;nbsp &lt;/td&gt; &lt;/tr&gt;&lt;/form&gt;"; echo "&lt;/table&gt;"; </code></pre> <p>My inputCheck function looks like this:</p> <pre><code>&lt;script type="text/javascript"&gt; function inputCheck(areaName) { console.log("checking..."); if (areaName.value.length &gt; 0) { $('form#AddNewService').submit(); } else { alert("You didn't describe the problem!"); } } // end noteCheck function &lt;/script&gt; </code></pre> <p>I tried changing the submit button to this:</p> <pre><code>&lt;input type=submit value=Save&gt; </code></pre> <p>but nothing happens, nothing on the page or in the log.</p> <p>Anyone have any idea as to what I am doing wrong or what the problem is here?</p> <p>Thanks in advance!</p> <p>EDIT:</p> <p>After using Steven's advice, I was able to successfully submit the form. However, the inputs aren't properly being sent. I am submitting to the same page so that the table reloads and and the user can see their latest entry. At the beginning of the script I have this:</p> <pre><code>if($AddNew == 'Yes') { echo "YES...Adding New"; echo $ticketid .$SiteID. $SiteName. $takenBy. $callTime. $caller. $callPhone. $issue. $fix. $solvedBy. $solvedTime; // Start SQL Query } </code></pre> <p>The inputs return null. Is there something wrong with the way I am setting my inputs? </p>
 

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