bubbles19518
02-17-2007, 01:49 AM
Im doing some PHP work for this guy, converting an old script to a new site. Here is a sample checkbox used in the script:
<input type=checkbox name=entries[] value=$rid onclick=Check(this,$rid)>
$rid is the value I want added to the entries[] array when they click the checkbox.
Here is the javascript
<script>
function DeleteAllEntries(url)
{
var msg = 'Delete all of your entries?\n\nYes - Click OK\nNo - Click Cancel\n\n'
+ 'Note that any new entries received from the\ntime this page was loaded will be deleted too.';
if(confirm(msg)) document.location.href = url;
}
function NumberOfChecks()
{
var cbs = document.getElementsByName('entries[]');
var i, n, num_checks;
n = cbs.length;
num_checks = 0;
for(i=0; i<n; i++)
{
if(cbs[i].checked) num_checks++;
}
return num_checks;
}
function EnableDisableDeleteButton()
{
var db = document.getElementById('delete_button');
if(NumberOfChecks()) db.disabled = false;
else db.disabled = true;
}
function SetTdStyle(td_id, bgcolor, bordercolor)
{
var td;
td = document.getElementById(td_id);
td.style.fontFamily = 'Verdana';
td.style.fontSize = '12px';
td.style.width = '90px';
td.style.backgroundColor = bgcolor;
td.style.borderWidth = '1px';
td.style.borderColor = bordercolor;
td.style.borderStyle = 'single';
}
function Check(this_cb, td_id)
{
var td;
td = document.getElementById(td_id);
if(this_cb.checked)
{
SetTdStyle(td_id, '#aa2222', '#000000');
}
else
{
td.setAttribute('bgColor','#FFFFFF');
SetTdStyle(td_id, '#ffffff', '#777777');
}
EnableDisableDeleteButton();
}
function CheckAll(this_cb)
{
var cbs = document.getElementsByName('entries[]');
var i, n, td, td_id;
n = cbs.length;
if(this_cb.checked)
{
for(i=0; i<n; i++)
{
cbs[i].checked = true;
td_id = 'td' + (i+8);
td = document.getElementById(td_id);
td.setAttribute('bgColor','#B0B0B0');
SetTdStyle(td_id, '#B0B0B0', '#000000');
}
}
else
{
for(i=0; i<n; i++)
{
cbs[i].checked = false;
td_id = 'td' + (i+1);
td = document.getElementById(td_id);
td.setAttribute('bgColor','#FFFFFF');
SetTdStyle(td_id, '#000000', '#000000');
}
}
EnableDisableDeleteButton();
}
function ConfirmDelete()
{
if(confirm('Delete the selected entries?'))
{
document.forms.delete_entries_form.submit();
}
}
function findPosX(obj){var curleft = 0;if(obj.offsetParent)while(1) {curleft += obj.offsetLeft;if(!obj.offsetParent)break;obj = obj.offsetParent;}else if(obj.x)curleft += obj.x;return curleft;}
function findPosY(obj){var curtop = 0;if(obj.offsetParent)while(1){curtop += obj.offsetTop;if(!obj.offsetParent)break;obj = obj.offsetParent;}else if(obj.y)curtop += obj.y;return curtop;}
function Details(dtid,dtdvid)
{
var dta=document.getElementById(dtid);
var dtdv=document.getElementById(dtdvid);
if(dtdv.style.display=='none')
{
dtdv.style.display='block';
var w;
if(window.innerWidth) w = window.innerWidth;
else if(document.body.offsetWidth) w = document.body.offsetWidth;
else w = 1024;
var x = (findPosX(dta)-90);
if(x < 10) x = 10;
if(x+90 > w) x = w - 90;
x = Math.floor(x);
dtdv.style.left = x + 'px';
dtdv.style.top = (findPosY(dta)+18) + 'px';
}
else
{
dtdv.style.display='none';
}
}
</script>
I submit the entries array with this code
<form method=POST action=delete.php name=delete_entries_form><input id=delete_button type=submit onclick=javascript:ConfirmDelete(); value=Delete Hit(s) disabled>
This code works on the old site, but wont work on the new one... I just need the value of the checkbox to be added to the entries array when the checkbox is checked
<input type=checkbox name=entries[] value=$rid onclick=Check(this,$rid)>
$rid is the value I want added to the entries[] array when they click the checkbox.
Here is the javascript
<script>
function DeleteAllEntries(url)
{
var msg = 'Delete all of your entries?\n\nYes - Click OK\nNo - Click Cancel\n\n'
+ 'Note that any new entries received from the\ntime this page was loaded will be deleted too.';
if(confirm(msg)) document.location.href = url;
}
function NumberOfChecks()
{
var cbs = document.getElementsByName('entries[]');
var i, n, num_checks;
n = cbs.length;
num_checks = 0;
for(i=0; i<n; i++)
{
if(cbs[i].checked) num_checks++;
}
return num_checks;
}
function EnableDisableDeleteButton()
{
var db = document.getElementById('delete_button');
if(NumberOfChecks()) db.disabled = false;
else db.disabled = true;
}
function SetTdStyle(td_id, bgcolor, bordercolor)
{
var td;
td = document.getElementById(td_id);
td.style.fontFamily = 'Verdana';
td.style.fontSize = '12px';
td.style.width = '90px';
td.style.backgroundColor = bgcolor;
td.style.borderWidth = '1px';
td.style.borderColor = bordercolor;
td.style.borderStyle = 'single';
}
function Check(this_cb, td_id)
{
var td;
td = document.getElementById(td_id);
if(this_cb.checked)
{
SetTdStyle(td_id, '#aa2222', '#000000');
}
else
{
td.setAttribute('bgColor','#FFFFFF');
SetTdStyle(td_id, '#ffffff', '#777777');
}
EnableDisableDeleteButton();
}
function CheckAll(this_cb)
{
var cbs = document.getElementsByName('entries[]');
var i, n, td, td_id;
n = cbs.length;
if(this_cb.checked)
{
for(i=0; i<n; i++)
{
cbs[i].checked = true;
td_id = 'td' + (i+8);
td = document.getElementById(td_id);
td.setAttribute('bgColor','#B0B0B0');
SetTdStyle(td_id, '#B0B0B0', '#000000');
}
}
else
{
for(i=0; i<n; i++)
{
cbs[i].checked = false;
td_id = 'td' + (i+1);
td = document.getElementById(td_id);
td.setAttribute('bgColor','#FFFFFF');
SetTdStyle(td_id, '#000000', '#000000');
}
}
EnableDisableDeleteButton();
}
function ConfirmDelete()
{
if(confirm('Delete the selected entries?'))
{
document.forms.delete_entries_form.submit();
}
}
function findPosX(obj){var curleft = 0;if(obj.offsetParent)while(1) {curleft += obj.offsetLeft;if(!obj.offsetParent)break;obj = obj.offsetParent;}else if(obj.x)curleft += obj.x;return curleft;}
function findPosY(obj){var curtop = 0;if(obj.offsetParent)while(1){curtop += obj.offsetTop;if(!obj.offsetParent)break;obj = obj.offsetParent;}else if(obj.y)curtop += obj.y;return curtop;}
function Details(dtid,dtdvid)
{
var dta=document.getElementById(dtid);
var dtdv=document.getElementById(dtdvid);
if(dtdv.style.display=='none')
{
dtdv.style.display='block';
var w;
if(window.innerWidth) w = window.innerWidth;
else if(document.body.offsetWidth) w = document.body.offsetWidth;
else w = 1024;
var x = (findPosX(dta)-90);
if(x < 10) x = 10;
if(x+90 > w) x = w - 90;
x = Math.floor(x);
dtdv.style.left = x + 'px';
dtdv.style.top = (findPosY(dta)+18) + 'px';
}
else
{
dtdv.style.display='none';
}
}
</script>
I submit the entries array with this code
<form method=POST action=delete.php name=delete_entries_form><input id=delete_button type=submit onclick=javascript:ConfirmDelete(); value=Delete Hit(s) disabled>
This code works on the old site, but wont work on the new one... I just need the value of the checkbox to be added to the entries array when the checkbox is checked