Solved

make a radio button go to anchor link on same page

Posted on 2004-04-08
2
2,884 Views
Last Modified: 2012-06-21
Hi,
  I was wondering if anyone could help me with my script.

I currently have a layer(stage2) appear when you select a radio button:

<input type="radio" name="radio1" value="One Time" onclick="expandcontent('stage2');" />


What I need is to somehow make the browser scroll down to the anchor link <a name="two"></a>
which is where the layer appears (which is at bottom of page).  But i want to insert something into this radio button tag....I just can't figure out how to do this...

Thanks for any help on this!
-Ron.


0
Comment
Question by:ron4721
2 Comments
 
LVL 16

Accepted Solution

by:
jaysolomon earned 250 total points
ID: 10786227
<input type="radio" name="radio1" value="One Time" onclick="expandcontent('stage2');window.location='#two';" />
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10786425
Or like this:

<html>
<head>
<script>
function expandcontent(divId){
  theDiv = document.getElementById(divId);
  theDiv.style.display='block';
  window.scrollTo(0,theDiv.offsetTop)
}
</script>
</head>
<body>
<form>
<input type="radio" name="radio1" value="One Time" onclick="expandcontent('stage2');" />
</form>
<div style="height:2000px"></div>
<div id=stage2 style="display:block">stage2</div>
<div style="height:2000px"></div>
</body>
</html>

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML5 Looping table certain Cell 11 54
Head to not include on scroll 4 23
Page auto-refreshes when scrolled on iPhone. 5 54
Html Newline 7 20
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 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