/    Sign up×
Community /Pin to ProfileBookmark

onClick problem

i have two radio box

<input type=”radio” name=”radio1″ value=”Y”>
<input type=”radio” name=”radio1″ value=”N”>

both with the same name, becos i only want them to choose either YES or NO ..

then i have another radio button which is in php command line.

echo “<input type=’radio’ name=’test’ value=’$row[pkey]’ onClick=’document.frm.radio1.value=”$row[answer]”;’>

i tried it but the radio button is not chosen and no errors also

i can do the onclick to a listbox(combox) or text box .. but not the radio button .. can anyone help me?

i want the radio1 value ‘Y’ button is chosen when the $row[answer] is “Y” and is clicked

please help me

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorMar 08.2004 — If you have two or more elements with the same name the object become an array of subelements, so you must treat them so

document.frm.radio1[0].value = 'Y'

document.frm.radio1[1].value = 'N'
Copy linkTweet thisAlerts:
@KorMar 08.2004 — on the other hand, to change dinamically the checked status, you have to use checked boolean attribute

document.frm.radio1[0].checked

or

document.frm.radio1[1].checked
×

Success!

Help @lting 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.18,
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,
)...