Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 01-12-2011, 01:00 PM   #1 (permalink)
Wise Old Owl
 
Cool Buddy's Avatar
 
Join Date: Mar 2006
Location: Milky way
Posts: 1,487
Default HTML help


In my website, I want to create a download button. The download button will point to either a word, excel or powerpoint file. This button will be used repeatedly. So I wrote the following code:

Code:
<style>
.downbut{
	width: 240px;
	height: 60px;
	border-left: 10px solid #79ba33;
	background-repeat: no-repeat;
}
#excel{
	background: url('excel.png');
}
#word{
	background: url('word.png');
}
</style>
and placed a link like this:

Code:
<a href="http://google.com"><div class="downbut" id="excel"></div></a>
This means I only need to change the ID to word or excel and the image will change.
This code worked perfectly on my PC when run locally. But when I put the same code on the server, it stops working. Also, it seems putting a div tag inside a link does not validate.

Any alternative idea how I could do this.
__________________
Digital Sheets Technology Blog
AMD Phenom II X4 840, 4 GB RAM, MSI HD5670, Corsair CX400 PSU :)
Nokia 5230 :(
Canon IXUS 115 HS :)
Cool Buddy is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-12-2011, 03:42 PM   #2 (permalink)
Right Off the Assembly Line
 
MarveL's Avatar
 
Join Date: Nov 2011
Location: in front of a computer
Posts: 12
Default Re: HTML help

Change the class instead of the id.
----------------------------------------------------


<html>
<head>
<title>CSS demo</title>
<style type="text/css">

div
{
width:200px;
height:30px;
}

div.divExcel
{
background:green;
}

div.divPPT
{
background:Orange;
}
</style>


</head>

<body>

<div class="divExcel">This is a DIV</div> <br/><br/>
<div class = "divPPT">This is a DIV</div>

</body>
</html>
MarveL is offline   Reply With Quote
Old 01-12-2011, 04:37 PM   #3 (permalink)
BIOS Terminator
 
nims11's Avatar
 
Join Date: Apr 2008
Location: Ranchi
Posts: 816
Default Re: HTML help

try this:

let the link be like
Code:
<a href="http://google.com" id="button0"><div class="downbut" id="excel"></div></a>
use this javascript:
Code:
<script type="text/javascript">
var button=document.getElementById("button0");
var str0=new String(button.firstChild.id);
if(str0=="excel")
button.firstChild.style.background="url('./excel.png')";
else if(str0=="word")
button.firstChild.style.background="url('./word.png')";
</script>
the javascript code should be inside the body and should come after the link.
__________________
Arch Linux is kind of a bonzai tree, over years u try new things, make small tweaks, and end up with a system that is unique, elegant, and does exactly what u designed it to do.
Hostapd : The Linux Way to create Virtual Wifi Access Point
My Blog
nims11 is online now   Reply With Quote
Old 01-12-2011, 07:54 PM   #4 (permalink)
Wise Old Owl
 
abhidev's Avatar
 
Join Date: Sep 2009
Posts: 1,624
Default Re: HTML help

use classes instead of id's as id's should be unique inside a page and you might have multiple docs of same format(word,excel..etc
)
Code:
<style>
.downbut{
width: 240px;
height: 60px;
border-left: 10px solid #79ba33;
background-repeat: no-repeat;
}
.excel{
background: url('excel.png');
}
.word{
background: url('word.png');
}
</style>
and placed a link like this:

div inside an anchor tag is not valid....so either use a <span> tag instead or simply give the class to the anchor tag itself.
Code:
<a href="http://google.com" class="downbut excel"></a>
__________________
Core 2 duo E4500 2.2gHz , ASUS P5GCMX , 3GB Transcend , Corsair VX 550w, MSI R5770 HAWK Edition 1GB, CM HAF-922, LG W2243T 21.5" LCD, I-Ball Baton
abhidev is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2