Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript works in Firefox but not in Chrome
    text
    copied!<p>My JavaScript code works fine in Firefox, but not in chrome. While in Firefox the correct number of forms (built by the code within the JavaScript function) are shown as soon as the option is selected, in Chrome nothing happens. I'm not sure why. I haven't checked in a while since I mostly use a Linux computer, but I believe IE9 works as well.</p> <p>If you could help me find I solution I'd appreciate it. By the way, I did read the other similarly titled question, but it didn't seem to answer this.</p> <pre><code>&lt;script type="text/javascript"&gt; function showForms(numForms) { // build the form var form = ""; for(i = 1; i &lt;= numForms; i++) { // define one section of the form (give fields unique names). var formPart = '&lt;fieldset&gt;&lt;legend&gt;Add User&lt;/legend&gt;&lt;label&gt;Full Name:&lt;/label&gt;&lt;input name="fullname' + i + '" type="text" required="required"" /&gt;&lt;label&gt;Email:&lt;/label&gt;&lt;input name="email' + i + '" type="email" /&gt;&lt;label&gt;Phone:&lt;/label&gt;&lt;input placeholder="1 (123)-123-1234" name="phone' + i + '" type="tel" /&gt;&lt;label&gt;Spreadsheet:&lt;/label&gt;&lt;input name="spreadsheet' + i + '" type="file" /&gt;&lt;label&gt;Registration #:&lt;/label&gt;&lt;textarea name="regnums' + i + '" placeholder="Aircraft registration number(s). Separate each number with a comma."&gt;&lt;/textarea&gt;&lt;/fieldset&gt;'; form = form + formPart; } // output the form to the page var output = document.getElementById("output"); output.innerHTML = form + '&lt;input name="numForms" value="' + numForms + '" type="hidden" /&gt;'; } &lt;/script&gt; </code></pre> <p>By the way, this function is called by <code>&lt;option onclick="showForms(#)"&gt;#&lt;/option&gt;</code> where # is the number of forms to be displayed. The options, of course, reside within a <code>&lt;select&gt;</code>.</p> <p>Thank you in advance for your help.</p> <p>EDIT: Here is the calling script, containing HTML, PHP &amp; JavaScript.</p> <pre><code>&lt;?php // include the javascript function to generate the form include ('../private/Includes/Scripts/showforms.js'); // form handling code if (isset($_POST['submit'])) { // make sure the input for the number of users is a number, and less than or // equal to 10 if (is_numeric($_POST['numForms']) &amp;&amp; $_POST['numForms'] &lt;= 10) { $regCount = $_POST['numForms']; } // initialize array for form data $regData = array(); // fill array with multi-dimentional form data for ($i = 1; $i &lt;= $regCount; $i++) { // get form data and store in temporary variables $fullname = trim($_POST['fullname' . $i]); $email = trim($_POST['email' . $i]); $phone = trim($_POST['phone' . $i]); $spreadsheet = $_POST['spreadsheet' . $i]; $regnums = trim($_POST['regnums' . $i]); // put data in array $regData[$i] = array( 'username' =&gt; '', 'fullname' =&gt; $fullname, 'email' =&gt; $email, 'phone' =&gt; $phone, 'spreadsheet' =&gt; $spreadsheet, 'regnums' =&gt; $regnums ); // unset temporary variables unset($invalid, $username, $fullname, $email, $phone, $spreadsheet, $regnums); } $errors = registerUsers($regData); if ($errors[0] == "Some users were not registered due to missing usernames.") { $notes[] = "Some users were not registered due to missing usernames."; unset($errors[0]); } if (!isset($errors)) { $success = true; } } ?&gt; &lt;h2 style="margin-top: -9px;"&gt;Register Users&lt;/h2&gt; &lt;p&gt;Use this form to register new users. Usernames and passwords are automatically generated and emailed to their owner's addresses.&lt;/p&gt; &lt;form enctype="multipart/form-data" method="post"&gt; &lt;fieldset&gt; &lt;legend&gt; Form Setup &amp;amp; Results &lt;/legend&gt; &lt;label&gt;No. of User(s):&lt;/label&gt; &lt;select onchange="showForms(0)" name="select"&gt; &lt;option selected="selected"&gt;- Please Select -&lt;/option&gt; &lt;option onclick="showForms(1)"&gt;1&lt;/option&gt; &lt;option onclick="showForms(2)"&gt;2&lt;/option&gt; &lt;option onclick="showForms(3)"&gt;3&lt;/option&gt; &lt;option onclick="showForms(4)"&gt;4&lt;/option&gt; &lt;option onclick="showForms(5)"&gt;5&lt;/option&gt; &lt;option onclick="showForms(6)"&gt;6&lt;/option&gt; &lt;option onclick="showForms(7)"&gt;7&lt;/option&gt; &lt;option onclick="showForms(8)"&gt;8&lt;/option&gt; &lt;option onclick="showForms(9)"&gt;9&lt;/option&gt; &lt;option onclick="showForms(10)"&gt;10&lt;/option&gt; &lt;/select&gt; &lt;/fieldset&gt; &lt;div id="output"&gt;&lt;/div&gt; &lt;input id="submit" name="submit" type="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre>
 

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