2

Folks,

First question here and trying to teach myself js and jquery, please forgive (or correct) any errors in nomenclature....

I am happily managing to pass through a variable from one page to another with this piece of code:

function openPage() {window.open('datapage_test.html?id=' + dataset[0].Var_Name)}

returns: file:///*path*/datapage_test.html?id=UK_Wakefield

When I try and extend this to pass multiple variables through I fail:

function openPage() {
    window.open('datapage_test.html?id=' + dataset[0].Var_Name + dataset[0].Var_Class + dataset[0].Var_Instance )
}

returns: file:///C:/*path*/datapage_test.html?id=WakefieldundefinedUK

All pointers gratefully received. J

1
  • 1
    It seems that dataset[0].Var_Class is undefined. Make sure you've spelled the property's name (Var_Class) correctly. Commented May 11, 2018 at 20:55

2 Answers 2

1

Urls are configure like this:

http://www.example.com/images/assets/file.html?id=1&type=2
protocol://domainName.com/path/to/myFile.html?parameter=value&other=value

This is your important part you are trying to do ?parameter=value&other=value

You can try something like this:

  function openPage() {window.open('datapage_test.html?id=' + dataset[0].Var_Name +'&val2=' + dataset[0].Var_Class +'&val3=' + dataset[0].Var_Instance )}

Hope this helps :)

Sign up to request clarification or add additional context in comments.

Comments

0

Starting variables in urls is done with ? which is what you are doing, however, for variables after that, you use &. For example, if I have the variables cat = meow and dog = woof, you could do http://example.com/?cat=meow&dog=woof.

Also, might want to check dataset[0].Var_Class. Apparently it's undefined in your example.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.