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
Solved

HTML radio input onclick problem

Posted on 2009-04-05
4
1,227 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
  • 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 500 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
AdminLTE with wordpress 15 133
innerHTML 7 34
Angular JS Sticky Footer Problem (when page size doesn't meet minimum) 4 28
How to resize a div in html 3 35
This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

789 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