/    Sign up×
Community /Pin to ProfileBookmark

Javascript Toggle Radio Buttons to Display Div

Hey everyone… I need some help, please.. lol…

I have a make payment page in which I’m using javascript to toggle some radio buttons to display the different payment options. I have 3 options. Here is my java script:

code:
function toggle(‘Check’, ‘Credit’, ‘EasyPay’ )
{
if (document.getElementById) {
target1 = document.getElementById(‘Check’);
target2 = document.getElementById(‘Credit’);
target3 = document.getElementById(‘EasyPay’);

if (target1.style.display == “none”){
target1.style.display = “”;
target2.style.display = “none”;
target3.style.display = “none”;
}

else if (target2.style.display == “none”){
target2.style.display = “”;
target1.style.display = “none”;
target3.style.display = “none”;
}

else (target3.style.display == “none”){
target3.style.display = “”;
target1.style.display = “none”;
target2.style.display = “none”;
}

It’s not working at all. Now, I don’t know if it makes any difference at all if my page is written all in php or not, but here’s the section that contains my radio buttons:

code:
print (“<div class=”row3″><p class=”pmtheads2″>Please choose one:</span> <label for=”label5″>Check</label><span class=”formw3″><input name=”PaymentType” type=”radio” value=”Check” onClick=”toggle(‘checkInfo’, ‘creditInfo’, ‘,’easyPay’)”id=”label5″></span>
<label for=”label6″>Credit</label><span class=”formw3″><input name=”PaymentType” type=”radio” value=”Credit” onClick=”toggle(‘creditInfo’, ‘easyPay’, ‘checkInfo’)” id=”label6″ ></span>
<label for=”label3″>EasyPay</label><span class=”formw3″><input name=”PaymentType” type=”radio” value=”EasyPay” onClick=”toggle(‘easyPay’, ‘checkInfo’, ‘creditInfo’)” id=”label3″></span></div><br>n”);

And then each option is contained within a div. Any ideas here? I can’t get the toggle function to work at all. It displays nothing when I try it.


_________________

Tek Angel

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@baseiberDec 22.2004 — Hi,

Have you tried the basic stuff like...

making sure all the curly braces are closed

tested to see if the call for the function is working

checking to see what you get when using document.getElementById

If not you might want to comment out most of the code and just leave
<i>
</i>function toggle('Check', 'Credit', 'EasyPay' )
{
alert('got here');
alert(document.getElementById);


If you've already tried this please ignore this post.

I don't know about the PHP as I don't know much beyond the basics.
Copy linkTweet thisAlerts:
@tek420angelauthorDec 22.2004 — Thank you very much. Problem solved.
×

Success!

Help @tek420angel 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.25,
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,
)...