IT Community - Software Programming, Web Development and Technical Support

convert a form field value in HH:MM:SS to pure seconds.

This is a discussion on convert a form field value in HH:MM:SS to pure seconds. within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... Can anybody tell me about How to convert a form field value in HH:MM:SS to pure ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-24-2007, 04:56 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default convert a form field value in HH:MM:SS to pure seconds.

Hi all...



Can anybody tell me about How to convert a form field value in HH:MM:SS to pure seconds?

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-24-2007, 05:10 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: convert a form field value in HH:MM:SS to pure seconds.

Hi all...


<SCRIPT LANGUAGE="JavaScript">
function splits(string,text) {
// splits string at text
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return;

var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return;
if (i == -1) {
splitArray[splitIndex++] = string;
return;
}

splitArray[splitIndex++] = string.substring(0,i);

if (i+txtLength < strLength)
splits(string.substring(i+txtLength,strLength),tex t);

return;
}

function split(string,text) {
splitIndex = 0;
splits(string,text);
}
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.1">
function split(string,text) {
splitArray = string.split(text);
splitIndex = splitArray.length;
}
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
var splitIndex = 0;
var splitArray = new Array();

function calculateTime() {
splitIndex = 0;
split(document.myForm.myTime.value,':');

for (var i=splitIndex-1, j=1, answer=0; i>=0; i=i-1, j=j*60)
answer += splitArray[i]*j - 0;

document.myForm.mySeconds.value = answer;
}
</SCRIPT>

<FORM NAME="myForm">
<P>HH:MM:SS = <INPUT NAME="myTime" TYPE="TEXT" MAXLENGTH="8" LENGTH="10">
<P>Seconds = <INPUT NAME="mySeconds" TYPE="TEXT">
<P><INPUT TYPE="BUTTON" VALUE="Calculate" onClick="calculateTime()">
</FORM>

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date/time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 1 02-06-2008 09:16 PM
Date/Time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 2 01-17-2008 07:47 PM
How can I clear the form field values after the user has submitted the form for clien itbarota HTML, CSS and Javascript Coding Techniques 1 11-01-2007 10:39 PM
How can I set the value of a fileupload form field? kingmaker HTML, CSS and Javascript Coding Techniques 0 10-31-2007 02:08 AM
How do I set the focus to the first form field? oxygen HTML, CSS and Javascript Coding Techniques 4 08-08-2007 02:02 AM


All times are GMT -7. The time now is 02:20 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0