Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Dynamic JQuery Objects Calling to Function


ZakAltF4 - 3:45 pm on Jan 16, 2012 (gmt 0)


Thanks for the welcome! I'll explain more in detail what I have going and display some of my actual code so it's easier to see...

From this:


<p><a href="#" onClick="addFormIm(); return false;" style="font-family:Arial, Helvetica, sans-serif; font-size:16px; color:#6633FF;">Add Image</a></p>


I am calling:


var iid=0;
function addFormIm() {
iid = iid + 1;
$("#divIm").append("<div id='irow" + iid + "'><img src=\"del.png\" style=\"vertical-align:middle;\" onClick='removeFormIm(\"#irow" + iid + "\",\"" + iid + "\"); return false;'>&nbsp;&nbsp&nbsp;&nbsp<a href=\"#\" onClick\"(Upload(" + id + "))\";>Upload Image</a><br><hr width=\"400\"><br></div>");
$("#containment-wrapper").append('<div id=\"AdIm' + iid + '\" style=\"width: 100px; height:100px; border:2px solid #ccc;\"><span id="mestatus' + iid + '" ></span><div id="files' + iid + '"><li class="success' + iid + '"></li></div></div></div>');
$( "#AdIm" + iid ).draggable({ containment: "#containment-wrapper", scroll: true });

$('#irow' + iid).highlightFade({
speed:1000
});
document.getElementById("iid").value = iid;
}
function removeFormIm(Riid,iid) {

$(Riid).remove();
var d = document.getElementById('containment-wrapper');
var olddiv = document.getElementById('AdIm' + iid);
d.removeChild(olddiv);
}


Creating these:

<div id='X'><img src="del.png" style="vertical-align:middle;" onClick='removeFormIm("#irowX","X"); return false;'>&nbsp;&nbsp&nbsp;&nbsp<a href="#" onClick"Upload(X)";>Upload Image</a><br><hr width="400"><br></div>


Calling Upload:


<script>
$(function Upload(id){
alert ('Image ID is ' + id + '!');


});
</script>



.... Everything works perfect, except for passing the ID to the upload function ... And when I check the CSS, the ID's are assigned properly. I just can't get them passed to the "Upload" function.

-- Zak


Thread source:: http://www.webmasterworld.com/javascript/4406594.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com