?
Solved

HTML radio input onclick problem

Posted on 2009-04-05
4
Medium Priority
?
1,231 Views
Last Modified: 2012-05-06
I have an html page with two radio buttons.  When the user clicks the radio button, it should trigger the url.

The following has the correct url, but does not go to that page.  What am I doing wrong?


        <td><input onclick="/myPage?key={{myData.key|stringformat:"s"|urlencode}}" type="radio" value="foo" name="s">1</td>


0
Comment
Question by:tmonteit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24071961
When using JavaScript to change location you have to either open in a new window, or adjust the windows current location.

Try the following:
<td><input onclick="window.location.href='/myPage?key={{myData.key|stringformat:"s"|urlencode}}'" type="radio" value="foo" name="s">1</td>

Open in new window

0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24071968
Also, I have just noticed that you have nested literals. Those need to be escaped.
<td><input onclick="window.location.href='/myPage?key={{myData.key|stringformat:\"s\"|urlencode}}'" type="radio" value="foo" name="s">1</td>

Open in new window

0
 

Author Comment

by:tmonteit
ID: 24071974
Can you post an example?  Thanks...

0
 
LVL 13

Accepted Solution

by:
numberkruncher earned 2000 total points
ID: 24071987
It should just be a case of replacing your original code with that suggested above.

Are you using PHP? If so then use code from my first response. If you actually intend "{{myData.key ..." to appear within the link then use the code from my second response.

See an additional simplified example below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>Demo Page</title>
	</head>
	<body>
		<h1>Demo Page</h1>
		<div>
			<input onclick="window.location.href='http://www.google.com'" type="radio" value="foo 1" name="s">
			<input onclick="window.location.href='http://www.google.com'" type="radio" value="foo 2" name="s">
		</div>
	</body>
</html>

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

800 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