Solved

Passing a variable via url, Javascript

Posted on 2014-02-28
2
317 Views
Last Modified: 2014-02-28
Hello! A couple of questions. The code below works great as long as the values aren't variables, but when they are variables it doesn't pass. So for example if I use the text "test" in place of thiscoursename in the url call, it works great. When I try to use the variable name, it doesn't.

Is there a special way of passing variables with javascript?

Thank you!


var thiscoursename="Test"

window.open("https://www.myurl.com/CompleteCourse/PostCompletedCourse?account=TestCo&firstname=Twenty&lastname=Eighth&coursename=thiscoursename&score=90", "_blank");
0
Comment
Question by:Karessa
[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
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39895666
Break out of your string, concatenate the variable (+) and then start your string again.

window.open("https://www.myurl.com/CompleteCourse/PostCompletedCourse?account=TestCo&firstname=Twenty&lastname=Eighth&coursename=" + thiscoursename + "&score=90", "_blank"); 

Open in new window

0
 

Author Closing Comment

by:Karessa
ID: 39895764
Brilliant! Thanks!
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

734 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