Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

make a radio button go to anchor link on same page

Posted on 2004-04-08
2
Medium Priority
?
2,891 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 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

824 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