F.N.G.
01-10-2003, 08:17 PM
Hello,
I would like to know how to modify the following script in order to cause a button to stay depressed, until another is clicked (which will then become depressed).
This script changes the color of buttons in such a manner, but I haven't yet found a reference for keeping a clicked button down.
Thanks for any help:
-----------------------------------------------------------------------------------
<html>
<head>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td>
<input type=text name=tex_t value=Text.>
<input type=button id=button0 value='button1' onclick="window.location.href='#">
<input type=button id=button1 value='button2' onclick="window.location.href='#">
<input type=button id=button2 value='button3' onclick="window.location.href='#">
<input type=reset id=button3 value='button4' onclick="window.location.href='#">
</td>
</tr>
</table>
<script language=JavaScript>
//Insert these lines into any place of page
//Set parameter "ID" for buttons so that it began with "butt".
//For example - "button1", "button2", "butt_shan"...
//You can use all types of buttons - "button", "submit", "reset".
//It is possible to add to them events. E.g. - onClick.
//---- Choice of variables ----\\
m_over_col="#ff9944"
m_out_col="#5555ee"
m_down_col="#90dd90"
m_over_col_tx="#4444ff"
m_out_col_tx="#ffffff"
m_down_col_tx="#000000"
//---------The description---------\\
/*
m_over_col - background of buttons at MouseOver
m_out_col - background of buttons at MouseOut and initial colors
m_down_col - background of buttons at MouseDown
m_over_col_tx - Color of text in buttons at MouseOver
m_out_col_tx - Color of text in buttons at MouseOut and initial colors
m_down_col_tx - Color of text in buttons at MouseDown
*/
//----------------------------------\\
//This and others free scripts you can find on a site: artdhtml.com
dow_key=''
window.onload=recolor_butt
function recolor_butt()
{
len_all=document.all.length
for (i=0; i<len_all; i++)
{
id=document.all[i].id
if (id.indexOf('butt')==0)
{
document.all[i].style.background=m_out_col
document.all[i].style.color=m_out_col_tx
}
}
}
function document.onmouseover()
{
id=window.event.srcElement.id
if (id.indexOf('butt')==0)
{
if(dow_key==id){return}
document.all[id].style.background=m_over_col
document.all[id].style.color=m_over_col_tx
}
}
function document.onmouseout()
{
id=window.event.srcElement.id
if (id.indexOf('butt')==0)
{
if(dow_key==id){return}
document.all[id].style.background=m_out_col
document.all[id].style.color=m_out_col_tx
}
}
function document.onmousedown()
{
id=window.event.srcElement.id
if (id.indexOf('butt')==0)
{
if(dow_key!=''){
document.all[dow_key].style.background=m_out_col
document.all[dow_key].style.color=m_out_col_tx
}
dow_key=id
document.all[id].style.background=m_down_col
document.all[id].style.color=m_down_col_tx
}
}
</script>
</body>
</html>
------------------------------------------------------------------------------------
I would like to know how to modify the following script in order to cause a button to stay depressed, until another is clicked (which will then become depressed).
This script changes the color of buttons in such a manner, but I haven't yet found a reference for keeping a clicked button down.
Thanks for any help:
-----------------------------------------------------------------------------------
<html>
<head>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td>
<input type=text name=tex_t value=Text.>
<input type=button id=button0 value='button1' onclick="window.location.href='#">
<input type=button id=button1 value='button2' onclick="window.location.href='#">
<input type=button id=button2 value='button3' onclick="window.location.href='#">
<input type=reset id=button3 value='button4' onclick="window.location.href='#">
</td>
</tr>
</table>
<script language=JavaScript>
//Insert these lines into any place of page
//Set parameter "ID" for buttons so that it began with "butt".
//For example - "button1", "button2", "butt_shan"...
//You can use all types of buttons - "button", "submit", "reset".
//It is possible to add to them events. E.g. - onClick.
//---- Choice of variables ----\\
m_over_col="#ff9944"
m_out_col="#5555ee"
m_down_col="#90dd90"
m_over_col_tx="#4444ff"
m_out_col_tx="#ffffff"
m_down_col_tx="#000000"
//---------The description---------\\
/*
m_over_col - background of buttons at MouseOver
m_out_col - background of buttons at MouseOut and initial colors
m_down_col - background of buttons at MouseDown
m_over_col_tx - Color of text in buttons at MouseOver
m_out_col_tx - Color of text in buttons at MouseOut and initial colors
m_down_col_tx - Color of text in buttons at MouseDown
*/
//----------------------------------\\
//This and others free scripts you can find on a site: artdhtml.com
dow_key=''
window.onload=recolor_butt
function recolor_butt()
{
len_all=document.all.length
for (i=0; i<len_all; i++)
{
id=document.all[i].id
if (id.indexOf('butt')==0)
{
document.all[i].style.background=m_out_col
document.all[i].style.color=m_out_col_tx
}
}
}
function document.onmouseover()
{
id=window.event.srcElement.id
if (id.indexOf('butt')==0)
{
if(dow_key==id){return}
document.all[id].style.background=m_over_col
document.all[id].style.color=m_over_col_tx
}
}
function document.onmouseout()
{
id=window.event.srcElement.id
if (id.indexOf('butt')==0)
{
if(dow_key==id){return}
document.all[id].style.background=m_out_col
document.all[id].style.color=m_out_col_tx
}
}
function document.onmousedown()
{
id=window.event.srcElement.id
if (id.indexOf('butt')==0)
{
if(dow_key!=''){
document.all[dow_key].style.background=m_out_col
document.all[dow_key].style.color=m_out_col_tx
}
dow_key=id
document.all[id].style.background=m_down_col
document.all[id].style.color=m_down_col_tx
}
}
</script>
</body>
</html>
------------------------------------------------------------------------------------