user1312390
user1312390

Reputation: 19

Javascript-function build url

I'm working on a project, and if I can get this to work it would save me a lot of time. I want to build a url in my javascript function, with the variable as part of the url. (I'm not good at javascript so I can't explain it properly... but I can show what I've got so far). It's more complicated, but it looks something like this:

I have this function (I know it doesn't work :-) ):

function art1(range) {
top.frames['infoframe'].location.href = 'http://url_part_1' + range + 'url_part_2.html';
}

And this in the body of my page:

<a href='some_other_url' onclick='some_other_functions();art1(C15)'   >

So the result should be this url:

http://url_part_1_C15_url_part_2

EDIT: Ok, additional problem: C15 is in another function, namely here:

function changeText(){
var newHTML = "<td class='tas'><a href='_some_link_' target='changer' 
onclick='setVisibility2();art1(C15)'   (...)

Upvotes: 1

Views: 1136

Answers (1)

Quentin
Quentin

Reputation: 943193

C15 is a variable (which is, presumably, undefined). You want a string literal instead: "C15".

Upvotes: 3

Related Questions