Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically Added Rows by jquery having issues
    primarykey
    data
    text
    <p>I have a form containing a select field id="projects" which upon being changed shows(using js) a hidden select field 'task' dynamically populating the tasks for the selected project by querying the dB. User can then enter hours which are updated on proj_id,task_id combination from the selects.</p> <pre><code>echo '&lt;div id="dynform"&gt;&lt;div class="rowhours"&gt;&lt;select id="projects" name="project"&gt;'; if(mysqli_num_rows($res)==0) echo '&lt;option&gt;No Projects assigned&lt;/option&gt;'; else{ echo '&lt;option value="0"&gt;Project - Choose one&lt;/option&gt;'; while (list($proj_id, $title) = mysqli_fetch_row($res)) { echo "&lt;option value=$proj_id&gt;$title&lt;/option&gt;"; } } echo '&lt;/select&gt;&lt;/div&gt;&lt;input type="button" id="add"&gt;&lt;/div&gt;'; &lt;select name="task" class="tasks" onchange="showOther(this, 'new');" onmouseover="showOther(this, 'new');"&gt;&lt;/select&gt;&lt;br&gt; function showOther(fieldObj, otherFieldID) //Function displays text box for creating a new task on Addhours.php { //for the selected project when "Enter New Task" option chosen var fieldValue = fieldObj.options[fieldObj.selectedIndex].value; var otherFieldObj = document.getElementById(otherFieldID); otherFieldObj.style.visibility = (fieldValue=='other') ? '' : 'hidden'; return; } </code></pre> <p>Now I added an 'Add Row' button, this generates the same form many times. </p> <pre><code>&lt;input type="button" value="Add Row" id="add"&gt; jquery used to add rows: $(document).ready(function () { $('#add').click(function () { $('.rowhours').clone().appendTo('#dynform'); }); }); </code></pre> <p>Now when I change the projects of any row, the tasks select fields of all rows get affected, I know this is because they have the same Id's. </p> <p>Question is how can I make them have different Id's and be able to use them seperately in the same manner using jquery. Also as of now I just update using the if(isset($_POST['submit'])) What can I use for the multiple rows now?</p> <p>I have a working example here <a href="http://fracktal.in/tms/addhours.php" rel="nofollow">http://fracktal.in/tms/addhours.php</a> </p> <p>I am basically looking for having a project[] and task[] that I have no clue how to access using jquery or to get the posted values on form submit to update dB</p>
    singulars
    1. This table or related slice is empty.
    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