I have a script where Javascript is used to control two buttons that are actioned by Perl.
The edit is a radio button and only one can be checked. It works fine.
The Delete is a checkbox will work when just one is checked.
Multiple deletes can wipe more than the records check, someitme the whole db.
An attempt at changing the checkbox to a radio button allowed multiple radio buttons to be checked – which is not the idea of radio buttons.
I know extremely little javascript so am asking if someone can please help with this, so that I can use a radio button instead of a checkbox for the delete and only one radio button is allowed to be clicked?
[CODE]
<SCRIPT LANGUAGE=”JavaScript”>
<!–
function submitForm(which) {
df = document.forum
// Delete – needs changing so only one radio button can be used at a time
if (which == ‘delete’) {
var str = “”
for (var i=0; i<13; i++) {
if (eval(‘df.delete’+i+’.checked == true’)) {
str += eval(‘df.delete’+i+’.value’)+”,”
}
}
if (str!=””) {
df.todelete.value = str.substring(0,str.length-1)
df.command.value = “deleteThreads”
df.submit()
}
else alert(‘Error: no threads to delete are selected’)
}
// edit ——- this works fine.
else if (which == ‘edit’) {
var editselected = false
if (df.toedit.length) {
for (var i=0; i<df.toedit.length; i++) {
if (df.toedit[i].checked == true) {
editselected = true
break
}
}
}
else {
if (df.toedit.checked == true) {
editselected = true
}
}
if (editselected == false) alert(‘Error: no thread to edit is selected’)
else {
df.command.value = “displayEditThread”
df.submit()
}
}
}
//–>
</SCRIPT>
Many thanks in advance.