Solved

Create an href link within my javascript code

Posted on 2010-08-21
10
467 Views
Last Modified: 2012-05-10
This should be really simple. I want to put a simple link in some output code that I have in javascript. The code I have is attached.

Why won't simple <a href> tags render in javascript?
options.statusUpdate = function( quizInfo, $currQuiz ){
        if( quizInfo.hasQuit ){
            var response = "If you are interested in receiving more information about spine care near you, we can help connect you with the experts in the Sutter Health network <a href="http://www.sutterhealth.org">Click Here</a> <br> <br> This information has been provided by Sutter Neuroscience Medical Group's spine surgeon <a href="http://www.sutterhealth.org/ProviderSearch/?sitecfg=75&action=providerdetail&masterid=5381&isLevelOne=">Dr. Gary Schneiderman.</a>"
			$( $currQuiz ).find( ".q-statDetails" ).hide();
			$( $currQuiz ).find( ".q-extraStat" ).html( response );

        }

Open in new window

0
Comment
Question by:modmedia
  • 5
  • 5
10 Comments
 
LVL 4

Expert Comment

by:UK_Andy
Comment Utility
0
 

Author Comment

by:modmedia
Comment Utility
Thanks Andy, but I've seen this already. My problem is that I am trying to implement this within a javascript script already. I have posted the entire code for reference. Towards the end is where you will find my first code snippet.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>Back Pain Quiz</title>
	<link rel="stylesheet" type="text/css" href="css/jQuizMe.css"/>
</head>
<body>
	<div id="quizArea"/>
</body>
<script type="text/javascript" src = "js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jQuizMe-uncompressed.js"></script>
<script type="text/javascript">
// There was an extra comma at the end of multiList array.
$( function($){
	var quizMulti = {
    multiList: [{
        ques: "The best over-the-counter medicine to take for back pain is:",
        ans: "All of the above",
        ansSel: ["Ibuprofen", "Acetaminophen (e.g., Tylenol)", "Asprin", null],
		ansInfo: "Acetaminophen will provide pain relief, while Ibuprofen and aspirin will help with the pain and reduce inflammation."
    },
	
	{
		ques: "The best exercise for a sore lower back is:",
        ans: "A long, slow walk",
        ansSel: ["A strenuous spinning class (work out the kinks)", "Yoga", null, "Nothing at all"],
		ansInfo: "Walking is a great way to gently exercise the back and eliminate the stiff, tight muscles that can lead to back problems. Avoid strenuous exercises and/or forced stretching that may aggravate the problem."

	},
	{
		ques: "Bed-rest is the best way to treat severe back pain",
		ans: "False",
		ansSel: ["True", null],
		ansInfo: "Generally, bed-rest is only beneficial for the first 1 - 2 days after onset of back pain. Prolonged bed-rest can result in a number of medical problems, including loss of muscle strength and even blood clots. Try to remain as active as possible for both your physical and mental well-being."
	
	},
	{
		ques: "Some lower back problems may be felt in the legs instead of the back itself, true or false?",
		ans: "True",
		ansSel: [null, "false"],
		ansInfo: "Lower back problems can lead to pressure on the nerves that go to your legs. This can cause pain on your legs, loss of feeling or weakness."
				
	},
	{
        ques: "What puts a person most at risk for back pain?",
        ans: "All of the above",
        ansSel: ["Weak abdominal muscles", "Long hours of sitting", "Being overweight", "Tight hip muscles", null],
		ansInfo: "Activity and exercise help reduce the incidence and intensity of back pain. Stretching reduces tight musculature which can contribute to back pain."
   
    },
	{
        ques: "What is the best kind of seating for someone with back pain?",
        ans: "Any seat with a pillow or support for the lower back and/or a chair with arms",
        ansSel: ["A wooden, straight-backed chair", "A reclining chair", "A soft, fluffy sofa", null],
		ansInfo: "The key is support. Look for seating that allows your feet to touch the ground while also supporting your lower back. Many seating arrangements can be made more back-friendly by simply placing a cushion behind the lower back."
    },
	{
		ques: "The more severe the back pain, the more likely a person needs surgery",
		ans: "False",
		ansSel: ["True", null],
		ansInfo:"Surgery for back pain is only indicated for very specific conditions. While severity and limitations of activity play a part in the decision process, the cause of pain is a very important part in the decision-making process regarding surgery."
		
    },
	{
		ques: "Which is most successful in treating back problems?",
        ans: "Varies depending on condition",
        ansSel: ["Chiropractic manipulation", "Regular massage and yoga", "Surgery", "Physical therapy", null],
		ansInfo: "The treatment is dependent on the type of symptoms, the physical exam and the diagnostic studies. All of the above treatments can play a part in treating your back pain. The treatment method is based on taking all three into consideration."
		
	},
	{
		ques: "What is the average recovery time for back pain?",
        ans: "2-6 weeks",
        ansSel: ["3-7 days", null, "2 months", "6 months"],
		ansInfo: "More than 90 percent of people with back pain will be better by six weeks."
	
	},
	{
		ques: "Which sleeping position is best for people who have back problems?",
        ans:  "On the side with a pillow between the knees",
        ansSel: ["Flat on the back with no pillow", "On the stomach", "On the back with support underneith the backs of the knees", null],
		ansInfo: "In general D, however any position that is comfortable is okay."
		
	},
	{
		ques: "You should see your doctor about back pain if:",
        ans:  "All of the above",
        ansSel: ["It doesn't improve after a few days", "It is accompanied by weakness or numbness in one or both of your legs", "It is accompanied by any loss of bladder or bowel control", "Any fever, history of infection or cancer, and/or pain that doesn't reduce with rest", null],
		ansInfo: "Any of the above could indicate the presence of a serious medical condition. Consult your physician if any of the above are present."
		
	}]		
	

	};
	options = {
		help: "All the information required can be found in the <a href='introduction/'>Introductory Lesson</a>. You can go through the lesson again if you struggle with this quiz.",
		showHTML: true,
		animationType: 0,
		showWrongAns: false,
		title: "Back Pain Quiz",
		help: 'None',
		disableRestart: true
};
options.allRandom = false;
options.random = false;
options.showAnsInfo = true;
// declare quiz and options 
options.statusUpdate = function( quizInfo, $currQuiz ){
        if( quizInfo.hasQuit ){
            var response = "If you are interested in receiving more information about spine care near you, we can help connect you with the experts in the Sutter Health network <a href="http://www.sutterhealth.org">Click Here</a> <br> <br> This information has been provided by Sutter Neuroscience Medical Group's spine surgeon <a href="http://www.sutterhealth.org/ProviderSearch/?sitecfg=75&action=providerdetail&masterid=5381&isLevelOne=">Dr. Gary Schneiderman.</a>";
			$( $currQuiz ).find( ".q-statDetails" ).hide();
			$( $currQuiz ).find( ".q-extraStat" ).html( response );

        }
 };
$("#quizArea").jQuizMe(quizMulti, options);
});
</script>
</html>

Open in new window

0
 

Author Comment

by:modmedia
Comment Utility
The code starts at line 110 as posted above
0
 
LVL 4

Expert Comment

by:UK_Andy
Comment Utility
I've noticed you have several a href link ref do they all not work correctly ?
0
 

Author Comment

by:modmedia
Comment Utility
right... the 2 that are in the "var response" array are the ones that do not work.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:UK_Andy
Comment Utility
<frameset rows="100%">
  <frame src="http://www.example.com/">
</frameset>
<noframes>
  <body>Please follow <a href="http://www.example.com/">link</a>!</body>
</noframes>
0
 

Accepted Solution

by:
modmedia earned 0 total points
Comment Utility
Thanks Andy, but that's not what I am looking for either. After googleing, I found that if I put the URL's in single quotes (') rather than double quotes (") it works.

Thanks for your efforts!
0
 
LVL 4

Expert Comment

by:UK_Andy
Comment Utility
0
 
LVL 4

Expert Comment

by:UK_Andy
Comment Utility
No problem glad you sorted it.
0
 

Author Comment

by:modmedia
Comment Utility
Thanks!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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)

772 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

11 Experts available now in Live!

Get 1:1 Help Now