fuction camActivation(){
if(activate==x){
document.writeln('<img src="ChillCam2.jpg" + height="255" + width="352" + name="ChillCam2" />');
}
}
Main Topics
Browse All TopicsAlright, this one has got to be easy. I'm just too new to javascript to figure out what I'm doing wrong.
I'm trying to have the HTML document run this line "<image src="mypic.jpg" height="255" width="352" name=myimage>" by changing a variable to X. Otherwise, if the variable is anything else I don't want any line to be written to the HTML document at all. I'm using this for a webcam and usually I have to search through the HTML document for this line and then comment it out when i don't want a pic to show.
This was my attempt:
<head>
<script language="JavaScript">
var activate = x;
fuction camActivation(){
activation = document.write('<image src="ChillCam2.jpg" + height="255" + width="352" + name=ChillCam2>');
if(activate=x)}
else {
document.write('')
}
</script>
</head>
--------------------------
<body>
<SCRIPT LANGUAGE="JavaScript">
camActivation();
</script>
</body>
Again, I'm fairly new to javascript so I may be totally off base with my approach.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
hi originsone
you need to put the script tags that print the line in the <body> part of the page
the if will detect the variable and execute or not : note the == in the test condition
the script in the body will fire as the page loads
<head>
<script language="JavaScript">
var activate = 15;
</script>
</head>
<body>
<script language="JavaScript">
if(activate==15)
{
document.writeln('<image src="ChillCam2.jpg" height="255" width="352" name=ChillCam2>');
}
</script>
</body>
Hi all,
Thank you all so much for your assistance with this. All seemed great answers...but jonnal's was the only I could seem to get to work correctly. However, If I changed the variabled to anything outside a number...it would not work properly. So, i couldn't use "No" or "Yes" as a variable instead of 15 (or any other number.
Eitherway, it worked!
Business Accounts
Answer for Membership
by: justinbilligPosted on 2004-11-29 at 10:02:16ID: 12698404
do something like this
e";
script language="javascript">
var g_strActivate = "yes";
function CamActivation( )
{
// Do we should the pic?
if( g_strActivate == "yes" )
{
// Yes
document.getElemntById( "webcam" ).style.visibility="visibl
}
}
</script>
<html>
<body onload="CamActivation( );">
<div id="webcam" style="visibility: hidden;">
<image src="mypic.jpg" height="255" width="352" name=myimage>
</div>
</body>
</html>