Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically created inputs with if else checkbox and multiple field validation
    text
    copied!<p>When the user clicks add more options, a from is created with javascript <code>document.getElementById('addmore').innerHTML</code>... It works great to display the form multiple times. I added a unique number each time to create unique IDs for each of the fields for submission. I have a checkbox that, if checked, needs to display another fields to get filled out: </p> <pre><code>document.getElementById('addmore').innerHTML += '&lt;p&gt;&lt;div class="required"&gt;*Type of Folder&lt;/div&gt;&lt;label for="it09" class="hidelabel"&gt;Content Drive&lt;/label&gt;&lt;input name="request['+fields+'][Type of Folder:]" id="cbpathCDB'+fields+'" type="checkbox" value="Content Drive" class="required" /&gt;&lt;strong&gt;Content Drive&lt;/strong&gt; (A: drive)&lt;br /&gt;&lt;div id="pathCDB'+fields+'"&gt;&lt;label for="newpathCDB"&gt;&lt;span class="req"&gt;*Path to Content Drive Folder&lt;/span&gt;&lt;/label&gt;&lt;input name="request['+fields+'][Path to Content Drive Folder:]" type="text" id="npcdb'+fields+'" size="50" class="required"/&gt;&lt;br /&gt;&lt;small&gt;Path of folder to be created on Content Drive (A: drive)&lt;br&gt;&lt;em&gt;(example: A:\drivefolder&lt;/em&gt;&lt;/small&gt;&lt;br /&gt;&lt;/div&gt;&lt;/p&gt;'; </code></pre> <p>I have tried multiple ways (jquery included) of getting the next div, pathCDB+fields, to show when the checkbox is checked. It works fine without the +fields in there... see <a href="http://jsfiddle.net/kuVzV/4/" rel="nofollow">http://jsfiddle.net/kuVzV/4/</a> however, when I add the fields it fails to show/hide with the checkbox. </p> <p>When the form is created though, the div doesn't show at first, just like it shouldn't... so I know the ID is correct. According to Firebug it is showing the correct ID with the field showing the correct # that is create... </p> <p>I am at a loss right now.</p> <p>Any suggestions on how to show/hide this div if the checkbox is checked for multiple inputs created dynamically?</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