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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.