Solved

Passing a variable via url, Javascript

Posted on 2014-02-28
2
295 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
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)

760 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

19 Experts available now in Live!

Get 1:1 Help Now