Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery - replace row with form
    primarykey
    data
    text
    <p>I have a html table that is generated by looping through DB entries. On the row is an edit button.</p> <pre><code>&lt;tr id="&lt;?php echo $i; ?&gt;"&gt; ... &lt;td&gt;&lt;button id="editbutton" onClick='edit("&lt;?php echo htmlentities($_SERVER['REQUEST_URI']); ?&gt;","&lt;?php echo $result_cameras[$i]["camera_name"]; ?&gt;", "&lt;?php echo $camera_quality; ?&gt;", "&lt;?php echo $camera_status; ?&gt;", "&lt;?php echo $email_notice; ?&gt;", "&lt;?php echo $result_cameras[$i]["camera_hash"]; ?&gt;")'&gt;Edit&lt;/button&gt;&lt;/td&gt; ... &lt;/tr&gt; </code></pre> <p>If you click the button it generates a form. Right now the form is just put below the table. Here is the edit function:</p> <pre><code>function edit(to, cameraname, cameraquality, camerastatus, emailnotice, camerahash) { var mydiv = document.getElementById("editform"); var myForm = document.createElement("form"); myForm.method = "post"; myForm.action = to; //camera name var label = document.createElement("label"); label.for = "text"; label.innerHTML="Camera name: "; myForm.appendChild(label); var myInput = document.createElement("input"); myInput.setAttribute("name", "camera_name"); myInput.setAttribute("value", cameraname); myForm.appendChild(myInput); //bunch of other code for different parts of the form... //submit changes button...doesn't do anything yet... mySubmit = document.createElement("input"); mySubmit.type = "button"; mySubmit.name = "apply_changes"; mySubmit.value = "Apply changes" myForm.appendChild(mySubmit); //cancel changes button...doesn't do anything yet... myCancel = document.createElement("input"); myCancel.type = "button"; myCancel.name = "cancel_changes"; myCancel.value = "Cancel" myForm.appendChild(myCancel); mydiv.appendChild(myForm); } </code></pre> <p>What I want to do is have the row in the table replaced by this form (in some sort of nicely formatted way). I thought I might be able to use jquery as I do have an id that I loop through for the table row. For example:</p> <pre><code>var js = jQuery.noConflict(); js(document).ready(function(){ js("#editbutton").click(function(){ js('#0').hide(); }); }); </code></pre> <p>This shows I can hide the first row by hard coding the first element (#0). I'm just not sure how to pull in the id based on the edit button row I just selected. Then change this row to show the form.</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.
    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