Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select fires up unrelated js ?

Status
Not open for further replies.

o5iri5

Programmer
Oct 12, 2007
2
ZA
Hi there,

I have a table with retracting cols, but withing the td's there are some select tags, and when clicked they fire up my onClick event from a completely different table

code snippet >>>
<HTML>
<HEAD><TITLE></TITLE>
<script type="text/javascript">
function expandIt(y) {
im_0 = document.getElementById("im_" + y);
frank = new Array(4) ;
for (i = 0; i <= 4; i++) {
frank = document.getElementById(y + "_" + i);
if (frank) {
if (frank.className == 'retract') {
frank.className = 'xpand';
im_0.src = "../images/minus.gif";
} else {
frank.className = 'retract';
im_0.src = "../images/plus.gif";
}
}
}
}
</script>
<STYLE>
.i_click{cursor :pointer;}
.xpand { visibility:visible;}
.retract{ visibility:collapse;}
</STYLE>
</HEAD>
<BODY>


<TABLE border="1">
<TR><TD><IMG src="../images/plus.gif" class="i_click" id="im_x" onClick="javascript:expandIt('x');"/></TD>
<TD>Column 2</TD></TR>
<TR><TD><IMG src="../images/plus.gif" class="i_click" id="im_y" onClick="javascript:expandIt('y');"/></TD>
<TD>Column 3</TD></TR>
</TABLE>

<TABLE border="1">
<TH>Heading 1</TH>
<TH>Heading 2</TH>
<TH>Heading 3</TH>
<TH>Heading 4</TH>
<TH>Heading 5</TH>
<TH>Heading 6</TH>
<TH>Heading 7</TH>

<col style="background-color: #6374AB; color: #ffffff" />
<col id="x_0" span="1" class="retract" style="background-color: #07B133; color: #ffffff;" />
<col id="x_1" span="1" class="retract" style="background-color: #CACACA; color: #ffffff;" />
<col id="x_2" span="1" class="retract" style="background-color: #CACACA; color: #ffffff;" />
<col id="y_1" span="1" class="retract" style="background-color: #CACACA; color: #ffffff;" />
<col id="y_2" span="1" class="retract" style="background-color: #CACACA; color: #ffffff;" />
<col style="background-color:yellow;"/>

<TR><TD>Col 1 Row 1</TD>
<TD>Col 2 Row 1</TD>
<TD>Col 3 Row 1</TD>
<TD><SELECT id="test" name="test"><OPTION>1</OPTION><OPTION>2</OPTION><OPTION>3</OPTION></SELECT></TD>
<TD>Col 5 Row 1</TD>
<TD>Col 6 Row 1</TD>
<TD>Col 7 Row 1</TD></TR>


</TABLE>
</BODY>
</HTML>

<<<
 
do you have some other Javascript either in the page or in an external JS file ? looking at this there should be no events triggered on the select, so you probably have some code somewhere else adding in events on the fly to the elements.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Nope. that's the whole page right there.
As soon as you click the select box and change the value and click anywhere else, the columns of the table go haywire...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top