/    Sign up×
Community /Pin to ProfileBookmark

Help with using variables between JS and HTML?

I’ve read quite a few different sites and examples using variables in Javascript, and found a couple that flat out state HTML does not support them. A developer from another site suggested in an e-mail that what I was seeking to do, is possible in the following way…

I have a template design that I’m working on, which I have a resized image as an anchor tag to a seperate HTM page, which I would like to use to turn on/off features with Javascript. I was told that I could accomplish what I was trying to do much easier with variables and simply enter the name of the JPG file with code, so that the information being placed into the anchor with the variable in the tag would then not only show up in the new window pic, but also view in the resized image link of the template. I’m not well versed with Javascript at all, having only tinkered around with a few different things and manipulated new codes for my use. If anyone knows how to achieve this goal and could point me in the right direction of tutorials, or in depth knowledge I’d appreciate it! The designer who sent me the examples below replied after I messed with the tags for quite some time, that she doesn’t use Javascript much and tries to stick with PHP and ASP…So I’m going to post the question and info she gave and see if anyone out there has an idea of the possibility of this working.

These would both have to be on the template page directing to the desired jpg you could change and view (which I’m guessing with the same one at the bottom to be entered into the second window’s script?!). I am clueless as to what is needed, as I’ve tried using this below changing the specified image files I entered with no luck at all. She later stated there needed to be a Javascript statement in the template to refer to the variable (which I do understand, as it is simply an undefined character at this point), but didn’t have much to say other than this, and that she tries to stick to the other two mentioned scripts. Anybody, make heads or tails of where I need to start looking for this one, or a quick fix for what I’m needing? Thanks for any time and help you can give! ?

<a href=http://www.yourwebsite.com/template.htm[COLOR=Red]?view=#####.jpg[/COLOR]>

<img src=”[COLOR=Red]?view[/COLOR]“>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceFeb 24.2006 — Your description takes so many loops and turns that it is difficult to get a clear idea of what you're talking about. So, just judging by the two HTML tags given, I'm going to presume that you wish to click on the indicated hyperlink and have it load a page which contains the indicated IMG tag. So, in the page with the indicated IMG tag, you can do this -- presuming nothing else in the URL query string:
<i>
</i>&lt;body&gt;
&lt;script&gt;
var str = self.location.search.substr(1);
if(str.length &gt; 0
&amp;&amp; str.substr(0,5) == "view=") {
document.writeln('&lt;img src="', str.substr(5), '" alt=""&gt;');
}
&lt;/script&gt;
&lt;/body&gt;
×

Success!

Help @mrmojorison 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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