Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing a variable via url, Javascript

Posted on 2014-02-28
2
Medium Priority
?
335 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

782 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