Solved

Problem with radio button not checked in form

Posted on 2004-08-14
3
295 Views
Last Modified: 2012-08-14
Hi All,
 When click on option 2,3,4 form changed but radio button not check.
Any help appreciated.

<html>
<head>

<script language="javascript">


function showHide(n) {
var eles = document.getElementsByTagName("div");
for(i=0;i<eles.length;i++) {
document.getElementById(eles[i].id).style.visibility="hidden";
}
for(i=0;i<eles.length;i++) {
if (eles[i].id==n) {
document.getElementById(n).style.visibility="visible";
}

}


}
</script>




<style type="text/css"><!--
#hotelbox { position: absolute; top: 16px; left: 16px; width: 100px; height: 100px; visibility: visible }
#customtripbox { position: absolute; top: 148px; left: 217px; width: 100px; height: 100px; visibility: hidden }
#carbox { position: absolute; top: 50px; left: 16px; width: 100px; height: 100px; visibility: hidden }
#lastmindealsbox { position: absolute; top: 60px; left: 20px; width: 100px; height: 100px; visibility: hidden }


-->
</style>
</head>

<body>
<div id="hotelbox">
This is hotelbox </div>
<div id="customtripbox">
This customtripbox </div>
<div id="carbox">
This is carbox </div>
<div id="lastmindealsbox">
This is lastmindealsbox </div>

<br><br><br><br><br><br><br><br><br><br>
<form>
<input type="radio" value="hotelbox" onClick="showHide('hotelbox');" checked >Option 1 </a><br>
<input type="radio" value="customtripbox" onClick="showHide('customtripbox');">Option 2 </a><br>
<input type="radio" value="carbox" onClick="showHide('carbox');">Option 3 </a><br>
<input type="radio" value="lastmindealsbox" onClick="showHide('lastmindealsbox');">Option 4 </a><br>

</form>
</body>
</html>
0
Comment
Question by:dl2y
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Colosseo earned 500 total points
Comment Utility
Hi dl2y

You appear to be missing the name value for the radio buttons. Try using this code below instead...

<form>
<input type="radio" value="hotelbox" name="boxOptions" onClick="showHide('hotelbox');" checked >Option 1 </a><br>
<input type="radio" value="customtripbox" name="boxOptions" onClick="showHide('customtripbox');">Option 2 </a><br>
<input type="radio" value="carbox" name="boxOptions" onClick="showHide('carbox');">Option 3 </a><br>
<input type="radio" value="lastmindealsbox" name="boxOptions" onClick="showHide('lastmindealsbox');">Option 4 </a><br>

</form>

Regards

Scott
0
 

Author Comment

by:dl2y
Comment Utility
Hi Scott,

It's working now. Thanks a lot

Regards,
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Hi dl2y

Np glad its working and thanks for the Grade

Regards

Scott
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now