I have a list of input1's and inputs2's. The input ones are an accept button and the input2's are a deny button. However, I set up an alert to tell me the name of the input 1's but I am only told the name of the last input1 in my list.
I would like input1.name to show me... something like accept[3]
Where 3 is the uid of the user being accepted or denied. The name works when I look at the source code, but fails when I try to create the alert.
How can I achieve this result?
Code:if (link) { link.onclick = function() { var uid = link.href.split('='); uid = uid[1]; ajax.get('/assets/ajax/partner_review.php?uid=' + uid, function(responce) { var info = eval('(' + responce + ')'); var i; lightbox.show(info[0], function(body) { for (i = 0; i < info[1].length; ++i) { var row = document.createElement('div'); var div1 = document.createElement('div'); var a = document.createElement('a'); var img = document.createElement('img'); var span = document.createElement('span'); var div2 = document.createElement('div'); var div3 = document.createElement('div'); var input1 = document.createElement('input'); var input2 = document.createElement('input'); var requestform = document.createElement('form'); input1.type = 'submit'; input2.type = 'submit'; input1.value = 'Accept'; input2.value = 'Deny'; input1.name = 'acceptrequest[' + info[1][i].uid + ']'; input2.name = 'denyrequest[' + info[1][i].uid + ']'; requestform.name = 'requestform'; requestform.method = 'post'; requestform.action = 'http://mysite.com/home.php'; a.href = 'http://mysite.com/u/' + info[1][i].username; a.setAttribute('target', '_blank'); addClass(row, 'lb_row'); img.src = info[1][i].avatar; img.alt = info[1][i].displayName; row.appendChild(div1); a.appendChild(img); div1.appendChild(a); addClass(div1, 'lb_div'); addClass(div1, 'tdfirst_review'); addClass(img, 'avatar extrasmall vmiddle'); span.appendChild(document.createTextNode(info[1][i].displayName)) a.appendChild(span); addClass(span, 'lb_span'); div2.appendChild(input1); row.appendChild(div2); addClass(div2, 'lb_div_button'); addClass(div2, 'lb_align'); div3.appendChild(input2); row.appendChild(div3); addClass(div3, 'lb_div_button'); addClass(div3, 'lb_align'); addClass(div3, 'right'); requestform.appendChild(row); body.appendChild(requestform); requestform.onsubmit = function () { /* So what to do here, thats the question - You want to get the data of the button that has been pressed, if such function exists. - Then use AJAX to send the form data to some file that probably doesnt exist yet. - Give the PHP a responce, and echot he response to replace the buttons */ input1.onclick = function () { alert(input1.name); } return false; } } }); }); return false; } }


Reply With Quote
Bookmarks