SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy how to display days , hours and minutes in my page which is comming from java script

    hi
    i got little problem. can you give me suggestion.
    Code:
    <script type = "text/javascript">
    var hours = document.getElementById("totalTime").value;
    var days = Math.floor(hours/24);
    var hrs = Math.floor(hours%24);
    var decimal = hours - Math.floor(hours);
    var minutes = Math.round(decimal * 60);
    
    document.getElementById("actualDays").value= +days+" Day(s) "+hrs+" Hour(s) "+minutes+" Minute(s)";
    
    </script>
    based on above script i am able to display my values in text box using getElementById("actualDays").value like below.
    Code:
    <input  name="actualDays"  id="actualDays" value="" size="30"  readonly="yes"/>


    but i need to display these values as a text values (using lable or span....).
    not in text box .can you help me for this

  2. #2
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Pennsylvania
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They are in the text box because you have it coded with the element id of "actualDays" inside an input field. What you need to do is instead use a div or p element and change the innerHTML. If you want it to be part of a line, and not stand on it's own, instead of the <div> use <span>.

    Instead of:
    <input name="actualDays" id="actualDays" value="" size="30" readonly="yes"/>

    Use:
    <div id="actualDays">&nbsp;</div>

    and in your Javascript instead of:
    document.getElementById("actualDays").value= +days+" Day(s) "+hrs+" Hour(s) "+minutes+" Minute(s)";

    Use this:
    document.getElementById("actualDays").innerHTML = days+" Day(s) "+hrs+" Hour(s) "+minutes+" Minute(s)";

    I hope that helps. You can contact me through my website: www.dynamicdzine.com if you have other questions about this particular problem.

  3. #3
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tahnk you

    Thank you so much. its working. i am very happy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •