I have an html table that pulls data from a DB. It has an edit button:
<button id="editbutton" onClick='edit2("<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>","<?php echo $result_cameras[$i]["camera_name"]; ?>", "<?php echo $camera_quality; ?>", "<?php echo $camera_status; ?>", "<?php echo $email_notice; ?>", "<?php echo $result_cameras[$i]["camera_hash"]; ?>")'>Edit</button>
I’m just passing in a number of things that I need to build the form. So that when the edit button is clicked it will create a form in javascript:
function edit2(to, cameraname, cameraquality, camerastatus, emailnotice, camerahash)
{
var mydiv = document.getElementById("editform");
var myForm = document.createElement("form");
myForm.method = "post";
myForm.action = to;
var label = document.createElement("label");
label.for = "text";
label.innerHTML="Camera name: ";
myForm.appendChild(label);
myInput = document.createElement("input");
myInput.setAttribute("name", "camera_name");
myInput.setAttribute("value", cameraname);
myForm.appendChild(myInput);
mydiv.appendChild(myForm);
}
Right now this contains only the processing for cameraname just for a proof point (which works). So now to the question. I’m starting to add some stuff with jquery so I also have:
var js = jQuery.noConflict();
js(document).ready(function(){
js('#webcamform').hide(); //initially hide form
js("#editbutton").click(function(){
js('#webcamform').show();//Form shows on button click
});
});
I want to add more neat jquery stuff. Keeping in mind that I can’t use Ajax at this point (Joomla reasons), should I combine this? All in jquery? How? Thanks in advance.
You can use it to simplify your dom element creation:
and then