/    Sign up×
Community /Pin to ProfileBookmark

Concatenating Characters

Hi,
I want to know if its possible to concatenate double quotes[“”] in a string?
I need to concatenate strings, so that the end result would look something like..

[“index.aspx?var1=var&var2=var2”]

the double quotes must be part of the string..

this is what i used…

val4=”&txt_var4=” + (getQueryVariable(“var4”));

but within the [“”] where its indicated as string, there must be another [“], how would I do something like that?

Thanks
SJB

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Mr_PantsAug 10.2006 — Hi SJB

Try 'escaping' the characters. To display quotes ["] try using a backslash [] in front of the character you want displayed. ie:

[CODE]val4=""&txt_var4="" + (getQueryVariable("var4"));[/CODE]

It's worth a try.

Regards

Martin ?
Copy linkTweet thisAlerts:
@sjbauthorAug 10.2006 — Thanks man, it worked...

Thanks
Copy linkTweet thisAlerts:
@sjbauthorAug 10.2006 — another question:

say for instance that this is the code I want to replace the following code:

<embed src="[B]psg_rate.swf?txt_var1=var1&txt_var2=var2&txt_var3=var&txt_var4=var4[/B]"

with the values that I got from the JavaScript, how do I do it??

This is the JavaScript that I used...


function showval()

{


var val1, val2, val3, val4, string;

val1=""psg_rate.swf?txt_var1=" + (getQueryVariable("var1"));

val2="&txt_var2=" + (getQueryVariable("var2"));

val3="&txt_var3=" + (getQueryVariable("var3"));

val4="&txt_var4=" + (getQueryVariable("var4")) + """;

string = val1 + val2 + val3 + val4;

alert(string);

}

how would I replace thi <embeded> tag with the result I got from this JavaScript?

Thanks
Copy linkTweet thisAlerts:
@Mr_PantsAug 10.2006 — Hi SJB

Glad the idea worked.

Your other question is a bit over my head as my knowledge of JavaScript is fairly limited, but, here goes.

You could try something along the lines of:

Remove the line alert(string);[/QUOTE] and then in place of the <embed> tag use [CODE]<script>document.write("<embed src='psg_rate.swf?"+string+">");</script>[/CODE]

I hope this helps or, at least, points you in the right direction.

Martin ?
Copy linkTweet thisAlerts:
@KorAug 10.2006 — Give your EMBED object and id, say "myembed":

<embed [B]id="myembed"[/B] src="psg_rate.swf?txt_var1=var1&txt_var2=var2&txt_var3=var&txt_var4=var4">

...

Now:
<i>
</i>var obj=document.getElementById('myembed')
var string='psg_rate.swf?'
for(var i=1;i&lt;=4;i++){
string+=('&amp;txt_var'+i+'='+getQueryVariable('var'+i))
}
obj.src=string

or use RegExp
<i>
</i>var obj=document.getElementById('myembed');
var string=obj.src;
for(var i=1;i&lt;=4;i++){
var r=new RegExp('var'+i,'g')
string=string.replace(r,getQueryVariable('var'+i))
}
obj.src=string
×

Success!

Help @sjb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...