image variables and tables

windows

Guest
I made a table with 1 row and several columns. Each cell has an image, for button usage later. I wanted text to be placed over the image and in the cell, so i made the image the background as opposed to using the 'img' tag. It worked fine.<br />
<br />
My problem is that i don't know how to use image variables with the background. I would use javascript to declare vars but then what? my table is not in script tags.<br />
<br />
<table align="center" border="0" cellpadding="0"><br />
<tr><br />
<td align="center" background="button.jpg" width="100" height="32" alt="" border="0">Button</td><br />
</tr><br />
</table><!--content-->So just add javascript around the table<br />
<br />
<script type="text/javascript"><br />
var add, your, vars;<br />
var dw=document.write; /* just makes it quikr to write */<br />
<br />
dw('<table align="center" border="0" cellpadding="0">');<br />
dw(' <tr>');<br />
dw(' <td align="center" background="button.jpg" width="100" height="32" alt="" border="0">Button</td>');<br />
dw(' </tr>');<br />
dw('</table>');<br />
</script><br />
<br />
then use image variables with the background like you wanted to... jaeman<!--content-->Originally posted by ShullDip <br />
<br />
<br />
My problem is that i don't know how to use image variables with the background. I would use javascript to declare vars but then what? my table is not in script tags.<br />
<br />
<br />
what image variables?<!--content-->dw(' </tr>');<br />
<br />
<br />
<br />
Hide any closing tags like '</tr>' that are within document.write statements by either breaking them open '</' + 'tr>' or by escaping them <\/tr> and the validator will no longer complain about these closing tags. If you break, then it is important to break directly after the / and not the middle of a word. Escaping the tag is better.<!--content--><script type="text/javascript"><br />
var add, your, vars;<br />
var dw=document.write; /* just makes it quikr to write */<br />
<br />
dw('<table align="center" border="0" cellpadding="0">');<br />
dw(' <tr>');<br />
dw(' <td align="center" background="button.jpg" width="100" height="32" alt="" border="0">Button</td>');<br />
dw(' </tr>');<br />
dw('</table>');<br />
</script><br />
<br />
ahh thanks. but how do i use the vars in the tag. lets say i declare the variable in the head like 'var imgbg="button.jpg"'. Then do i just replace 'background="button.jpg"' with 'background=imgbg' or what? i tried this and also putting the var in quotes but no dice. Im sorry im a total newb with this stuff.<!--content-->Originally posted by scoutt <br />
what image variables? <br />
like I said<br />
<br />
what image variables and why do you want a variable?<!--content-->does he mean setting height and width of a background image?<!--content-->Originally posted by scoutt <br />
like I said<br />
<br />
what image variables and why do you want a variable? <br />
<br />
what do you mean what image variable? the name of the variable? The location of it?<br />
<br />
I sorta just want to learn how to use variables in place of anything. The other reason is so i can someday(when i learn how to do functions) set the variable to another variable during certain mouseover events.<!--content-->Hi there ShullDip,<br />
<br />
I may have misread your original post..<br />
but it seems that you want something like this...<html><br />
<head><br />
<style type="text/css"><br />
<!--<br />
td<br />
{<br />
background:url(button.jpg);<br />
width:100px;<br />
height:32px;<br />
text-align:center;<br />
}<br />
a<br />
{<br />
font-family:arial; <br />
font-size:20px;<br />
color:#00ff00;<br />
text-decoration:none;<br />
}<br />
//--><br />
</style><br />
</head><br />
<body><br />
<table align="center" ><br />
<tr><br />
<td ><a href=http://www.htmlforums.com/archive/index.php/"some.html">Button</a></td><br />
</tr><br />
</table><br />
</body><br />
</html><br />
<br />
c:cool::cool:thead<!--content-->I'm not sure exactly what you want. There are no variables in HTML, you will need javascript which I think is what you are going to do. Now that we have that out of the way, what exactly is it you want to do?<!--content-->he wants this<br />
<br />
<script type="text/javascript"><br />
var add = "button.jpg";<br />
var dw=document.write; /* just makes it quikr to write */<br />
<br />
dw('<table align=\"center\" border=\"0\" cellpadding=\"0\">');<br />
dw(' <tr>');<br />
dw(' <td align=\"center\" background=\" + add + \" width=\"100\" height=\"32\" alt=\"\" border=\"0\">Button</td>');<br />
dw(' </tr>');<br />
dw('</table>');<br />
</script><br />
<br />
but there is no reason to do that as you are in javascript and not html. what I jus tdid would be pointless as it creates more code than you really need.<!--content-->or you could just add the text over it in some graphic editor.<!--content-->Well im trying to make it so that when someone hovers a button link, the button changes to a gif of the same size. I'm reading over someone elses script and trying to figure out how to do it, but if anyone can help a javascript illiturate i'd appreciate it.<br />
<br />
here's the line of the button..<br />
<br />
dw('<td background="button.jpg" align="center" width="100" height="32" alt="" border="0"><a href=http://www.htmlforums.com/archive/index.php/"url.com"> click here</a><\/td>');<!--content-->you have a link and you want to make a image appear over it when you hover?<br />
<br />
that has nothing to do with the code we are talking about.<br />
<br />
that means doing somethign totally different.<br />
<br />
do you even know what you want?<!--content-->lol yes, well, sorta. I wanted to know how to do something, which was first how to use html in a js script. Ultimately, i wanted to know how to replace background cell images using a mouseover/out event. I thought it had to do with vars, which was something i wanted to learn anyway. The reason why i didn't use text in the creation of the image was for versitility.<!--content-->giz<br />
Hide any closing tags like '</tr>' that are within document.write statements by either breaking them open '</' + 'tr>' or by escaping them <\/tr> and the validator will no longer complain about these closing tags. If you break, then it is important to break directly after the / and not the middle of a word. Escaping the tag is better. <br />
<br />
i was unaware it would cause a problem, then again if i took into practise some perl functions or Cpp that is exactly right, thanks... jaeman<!--content-->
 
Back
Top