/    Sign up×
Community /Pin to ProfileBookmark

JS controlled buttons problem

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>
[/CODE]

Many thanks in advance.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@edatzauthorAug 06.2009 — Scrap this. I decided to rewrite the Perl script entirely and not use any JS to control the

buttons.
×

Success!

Help @edatz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...