Jump to content

Please Help! Issues with javascript min sec timer based on ID


blogscrubber

Recommended Posts

I have been working on this the past two days and the code below works without the +type+id... I need to get the timer working with +type+id or it is useless to me!

 

PLEASE PLEASE HELP!

 

function getTime(min, sec, type, id) {
var min = document.getElementById("editTimeminutes"+type+id).innerHTML;
var sec = document.getElementById("editTimeseconds"+type+id).innerHTML;

var minfield = "editTimeminutes"+type+id;
var secfield = "editTimeseconds"+type+id;

// function display() {
sec--;
  if (sec == -01) {
sec = 59;
    min = min - 1;
  } else {
   min = min;
  }
if (sec<=9) { 
sec = "0" + sec; 
}
    minutes = min<=9 ? "" + min : min;
    seconds = sec;

document.getElementById(minfield).innerHTML = minutes; 
document.getElementById(secfield).innerHTML = seconds; 
// }

if (min == '0' && sec == '00') 
{ 
sec = "00"; window.clearTimeout(SD); 
document.getElementById("editTimeminutes"+type+id).style.display = 'none';
document.getElementById("editTimeseconds"+type+id).style.display = 'none';
document.getElementById("mintxt"+type+id).style.display = 'none';
document.getElementById("sectxt"+type+id).style.display = 'none';
}

SD=window.setTimeout("getTime();", 1000);
// display();
}

 

below are the fields and script to execute this function

 

<table width="100%">
<tr><td width="100%" align="center">

<span id="editTimeminutes12" class="timeClass" style="display:visible;">4</span> <span id="mintxt12">min</span> <span id="editTimeseconds12" class="timeClass" style="display:visible;">12</span> <span id="sectxt12">sec left to edit</span>
<br/><br/>

<span id="testValues"></span>
</td></tr>
</table>
<script language="javascript">
getTime(4,12,1,2)
</script>

<table width="100%">
<tr><td width="100%" align="center">

<span id="editTimeminutes13" class="timeClass" style="display:visible;">2</span> <span id="mintxt13">min</span> <span id="editTimeseconds13" class="timeClass" style="display:visible;">31</span> <span id="sectxt13">sec left to edit</span>
<br/><br/>

<span id="testValues"></span>
</td></tr>
</table>
<script language="javascript">
getTime(2,31,1,3)
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.