Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing a variable via url, Javascript

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

661 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