Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Javascript in conditional relationships

Hi all

We have a conditional relationship set where we use javascript to toggle a pop-up.  Problem is that if it comes up more than once in a task, the first one on the page gets the nod (so clicking a "what's included" link on the right might, in some circumstances, cause a pop-up further to the left).

Here's a sample of the code:

<head>
<script type="text/javascript">
 
function toggle(id) {
  var e = document.getElementById(id);
 
  if (e.style.display == '')
    e.style.display = 'none';
  else
    e.style.display = '';
}
 
</script>
</script>
</head>
<center><font size="1" color="#A4A4A4"><a href="#" onclick="toggle('what inc1')"><i>What's Included</i></a></center>

<div id="what inc1" style="display:none">
</font>
<font size="1" color=""><table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
  <td width ="5%" valign="top"> &#149; </td>
  <td> National calls, SMS and MMS to standard Australian landline and mobile numbers </td>
</tr>
<tr>
  <td width ="5%" valign="top"> &#149; </td>
  <td> Calls to 13xx and 1800 numbers </td>
</tr>
</table></font>
</div>


We COULD use an attribute instead, but we're already using 30 attributes and on Version 7 that's our limit.  So the question for all those Javascript experts out there ... is there a way to make the toggle name - ie 'what inc1' - to be different if it is called twice on the same page?
asked Oct 29, 2012 by Marion Bronze (3,600 points)
why don't you set the hidden divs positions based on mouse or event generating frame's clientLeft?

1 Answer

0 votes
Can attach the event to/preform action on the specific table cell using the jQuery .eq() function.

For example to attach to the 3rd cell in the 2nd row:

$('.cbc_row_2 td').eq(2).click(function(){alert("hi")});

If you're using SSI Web 7 or below will need to include jquery and enclose in a noConflict block.
answered Oct 30, 2012 by anonymous
...