Simple javascript: why won't it work cross-browser?

I am trying to use Javascript for a series of menu buttons. When clicked, I want to enter text into a hidden field, and change the border around the clicked icon. My code works fine in Firefox, but not in other browsers. Please advise.


Sample link:
 
<a href="javascript:setButton4();" onClick="javascript:document.forms['search'].cat.value='Toys';" onMouseUp="setButton4();">
 
The javascript functions:
 
function setButton1()  {
	document.button1.style.borderWidth="5"
	document.button2.style.borderWidth="1"
	document.button3.style.borderWidth="1"	
	document.button4.style.borderWidth="1"	
	document.button5.style.borderWidth="1"	
	document.button6.style.borderWidth="1"	
	document.button7.style.borderWidth="1"		
}
function setButton2()  {
	document.button1.style.borderWidth="1"
	document.button2.style.borderWidth="5"
	document.button3.style.borderWidth="1"	
	document.button4.style.borderWidth="1"	
	document.button5.style.borderWidth="1"	
	document.button6.style.borderWidth="1"	
	document.button7.style.borderWidth="1"	
}
function setButton3()  {
	document.button1.style.borderWidth="1"
	document.button2.style.borderWidth="1"
	document.button3.style.borderWidth="5"	
	document.button4.style.borderWidth="1"	
	document.button5.style.borderWidth="1"	
	document.button6.style.borderWidth="1"	
	document.button7.style.borderWidth="1"	
}
function setButton4()  {
	document.button1.style.borderWidth="1"
	document.button2.style.borderWidth="1"
	document.button3.style.borderWidth="1"	
	document.button4.style.borderWidth="5"	
	document.button5.style.borderWidth="1"	
	document.button6.style.borderWidth="1"	
	document.button7.style.borderWidth="1"	
}
function setButton5()  {
	document.button1.style.borderWidth="1"
	document.button2.style.borderWidth="1"
	document.button3.style.borderWidth="1"	
	document.button4.style.borderWidth="1"	
	document.button5.style.borderWidth="5"	
	document.button6.style.borderWidth="1"	
	document.button7.style.borderWidth="1"	
}
function setButton6()  {
	document.button1.style.borderWidth="1"
	document.button2.style.borderWidth="1"
	document.button3.style.borderWidth="1"	
	document.button4.style.borderWidth="1"	
	document.button5.style.borderWidth="1"	
	document.button6.style.borderWidth="5"	
	document.button7.style.borderWidth="1"	
}
function setButton7()  {
	document.button1.style.borderWidth="1"
	document.button2.style.borderWidth="1"
	document.button3.style.borderWidth="1"	
	document.button4.style.borderWidth="1"	
	document.button5.style.borderWidth="1"	
	document.button6.style.borderWidth="1"	
	document.button7.style.borderWidth="5"	
}

Open in new window

jpschreibmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

silemoneCommented:
it may be that  other styles are overriding

if this doesn't work, you could check which browser is being used and based upon that set the borderwidth accordingly where it shows up identical all browsers...
0
quincydudeCommented:
Hi,
Cannot test your code without the html, but you can merge this
onClick="javascript:document.forms['search'].cat.value='Toys';" onMouseUp="setButton4();"
to just
onClick="document.forms['search'].cat.value='Toys';setButton4();"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jpschreibmanAuthor Commented:
No other styles are overriding. It simply is not working in IE.

Thanks for trying.

The HTML is attached below:

	<fieldset>
	<legend>Find More Presents!</legend>
			<form name="search" action="./?page=users_home&act=MORE#look" method="post">
	<table>
	<tr>		
		<td><a href="javascript:setButton4();" onClick="javascript:document.forms['search'].cat.value='Toys';" onMouseUp="setButton4();javascript:document.forms['search'].keyword.value='What type of toys are you looking for?';"><img id="button4" width="85" src="./theme/images/icon_toys.png"  border="5" ></a></td>		
		<td><a href="javascript:setButton5();" onClick="javascript:document.forms['search'].cat.value='VideoGames';javascript:document.forms['search'].keyword.value='What type of video games are you looking for?';" onMouseUp="setButton5();"><img id="button5" width="85" src="./theme/images/icon_games.png"  border="1" ></a></td>			
		<td><a href="#" onClick="javascript:document.forms['search'].cat.value='Books';javascript:document.forms['search'].keyword.value='What type of book are you looking for?';" onMouseUp="setButton1();"><img id="button1" width="85" src="./theme/images/icon_books.png"  border="1" ></a></td>
 
		<td><a href="#" onClick="javascript:document.forms['search'].cat.value='DVD';javascript:document.forms['search'].keyword.value='What type of movie or DVD are you looking for?';" onMouseUp="setButton2();"><img id="button2" width="85" src="./theme/images/icon_movies.png"  border="1" ></a></td>
		<td><a href="#" onClick="javascript:document.forms['search'].cat.value='Music';javascript:document.forms['search'].keyword.value='What type of music are you looking for?';" onMouseUp="setButton3();"><img id="button3" width="85" src="./theme/images/icon_music.png"  border="1" ></a></td>		
		<td><a href="#" onClick="javascript:document.forms['search'].cat.value='Apparel';javascript:document.forms['search'].keyword.value='What type of clothes are you looking for?';" onMouseUp="setButton6();"><img id="button6" width="85" src="./theme/images/icon_clothes.png"  border="1" ></a></td>				
		<td><a href="#" onClick="javascript:document.forms['search'].cat.value='Tools';javascript:document.forms['search'].keyword.value='What type of tools are you looking for?';" onMouseUp="setButton7();"><img id="button7" width="85" src="./theme/images/icon_tools.png"  border="1" ></a></td>				
		<td><a href="#" onClick="javascript:document.forms['search'].cat.value='Electronics';javascript:document.forms['search'].keyword.value='What type of electronics are you looking for?';" onMouseUp="setButton8();"><img id="button8" width="85" src="./theme/images/icon_electronics.png"  border="1" ></a></td>				
	<tr><td colspan="10" style="padding:10px;" bgcolor="#000033"><font color="#ffffff"><b>Search for:</b></font> <input type="text" size="45" name="keyword" value=""> <input class="submit" type="submit" value="go!"></td></tr>
	</table>
	<input type="hidden" name="cat" id="cat" value="Toys">
	<p>Want to browse the regular Amazon.com site? <a class="gen_link" href="http://www.amazon.com/?&tag=mychristma077-20&camp=211173&creative=374757&linkCode=ur1&adid=0MYJDPQBZ3ZBWY3TTZ64&" target="_blank">Click here!</a></p>
 
	</fieldset>
	</form>

Open in new window

0
quincydudeCommented:
Do not use
document.button7.style.borderWidth

try to change to

document.getElementById("button7").style.borderWidth
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.