dcsimg
Results 1 to 8 of 8

Thread: [RESOLVED] <script> $(function () { var d = new Date() var h12

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    65

    Resolved [RESOLVED] <script> $(function () { var d = new Date() var h12

    What is wrong with this code?
    Code:
      <script>
             $(function () { 
               var d = new Date()
               var h12 = d.getHours();
               var h24 = d.getHours();
               var m = d.getMinutes();
               var s = d.getSeconds();
               if (s < 10) {
                   s = "0" + s
               }
               if (m < 10) {
                   m = "0" + m
               }
               if (h12 > 12) {
                   h12 = h12 - 12
               }
               if (h12 == 00) {
                       h12  = 12
                   }
    
               var timeStamp = h12 + ":" + m + ":" + s + " ";
               if (h24 > 11) {
                   timeStamp += "PM";
               } else {
                   timeStamp += "AM";
               }
    
               var userName = document.getElementById("myUserName").value;
               var img = $('<img width="100px;" height=" 100px">');
              $("div.dropdown-menu a").click(function () {
              $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
              $('#conDivID').append('</br>');
              $("#conDivID").append($(this).find("img").clone(true)); 
              $('#conDivID').append('</br>');
              $('#conDivID').append("<span class='timeSpan'>" + timeStamp + '</span>');
              $('#conDivID').append('</br>');
                   
             });
             })
         </script>
    It's not working it used to sent image(emoji) from dropdown menu to conversation box as in the whole code below
    [CODE]<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <script
    src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
    </script>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

    </head>
    <body>
    <div class=" bannerDiv">
    <img style="width:40px"height:40px"
    src="https://imgur.com/57AweD4.png" alt="LOGO" />
    <span style="font-family: Times New Roman ;font-size: 30px; color: red">
    RedAppleChat</span>
    </div>

    <form>
    <div class=" UsernameLabelDiv">
    <input style="width: 300px" type="text" placeholder="Username" id="myUserName"maxlength="10"onkeyup="saveValue(this)" onkeypress="return AvoidSpace(event)">
    </div>
    <div class="conDiv" id="conDivID"></div>

    <div class=" myInputtextDiv">
    <input style="color:black;" type="text" id="myInput" maxlength="10000" >

    <input type="text" id="baseimage" onkeyup=" sendImage()" hidden >

    </br>

    <a id="myBtn" class="btn btn-primary btn-sm"onclick="sendFunction();">
    <span class="glyphicon glyphicon-send"></span> Send
    </a>
    <input id="fileInput" type="file" style="display: none;" />
    <a id="fileInput" class="btn btn-success btn-sm" type="file"onclick="document.getElementById ('fileInput').click();">
    <span class="glyphicon glyphicon-camera"></span> Image!
    </a>
    <a id="myBtn" class="btn btn-danger btn-sm" onclick="clearChat();">
    <span class="glyphicon glyphicon-trash"></span> Clear
    </a>
    <!--To record voice -->
    <input id="fileInput" type="file" style="display: none;" />
    <a type="file"onclick="document.getElementById ('fileInput').click();">
    <img src="https://imgur.com/Go9vKSd.png" width=" =20px;" height=" 20px" alt=".."/>
    </a>
    <!--To add stickers-->
    <div class="btn-group" style="display:inline;position: absolute; direction:ltr">
    <button type="button"
    class="btn btn-outline-light btn-sm dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
    <img src="https://imgur.com/PVBYWRJ.png
    "width=" =20px;"height=" 20px"alt=".."></button>

    <div class="dropdown-menu" >

    <a class="dropup-item"
    <button ><img src="https://imgur.com/zLXQ7Ua.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/u82MtgI.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/5DJF0bU.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/Go9vKSd.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/JGIGROu.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/7ECo6jN.png "
    width=" =20px;" height="20px"alt=".."> </button></a>


    <br/>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/PVBYWRJ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bgOYEUb.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/UCi89or.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/Bj4xOS9.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/7QNYfSh.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/6sqrgNK.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/Dt3VM26.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/yBUGgCQ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>


    <a class="dropdown-item"
    <button ><img src="https://imgur.com/XNXYKlC.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/IZh9H8B.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bYTUGeR.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bYTUGeR.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <br/>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/GZC0Mga.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/HE2E2sL.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/D9DshnJ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/rKS2mLu.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/wgmmMJM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/00zu1KL.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/2DoStHY.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/1x3bgVM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/IBA9mXh.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/98EIMUt.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/yuLJrdH.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/AqWbP2a.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/mCjBjMP.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/ZLVruHF.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/5IqJpdY.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/wkjgd5T.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/qbeRdCr.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/aFCkpNZ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/RV84irI.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/OWGw5bW.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/XFGjDSL.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/G2lMKBM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bxtFpmf.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/zX9o3nM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/kFp9RpM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/IjZSn44.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/YlsSaRf.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/0Z8aJ75.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/LFCpFRE.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/YP5l3HU.png "
    width=" =20px;" height="20px"alt=".."> </button></a>


    </div>
    </div>
    </div>
    <br>

    <script>
    $(function () {
    var d = new Date()
    var h12 = d.getHours();
    var h24 = d.getHours();
    var m = d.getMinutes();
    var s = d.getSeconds();
    if (s < 10) {
    s = "0" + s
    }
    if (m < 10) {
    m = "0" + m
    }
    if (h12 > 12) {
    h12 = h12 - 12
    }
    if (h12 == 00) {
    h12 = 12
    }

    var timeStamp = h12 + ":" + m + ":" + s + " ";
    if (h24 > 11) {
    timeStamp += "PM";
    } else {
    timeStamp += "AM";
    }

    var userName = document.getElementById("myUserName").value;
    var img = $('<img class="img" width=" =100px;" height=" 100px">')
    .attr('src', imagesrc.value);
    $("div.dropdown-menu a").click(function () {
    $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
    $('#conDivID').append('</br>');
    $("#conDivID").append($(this).find("img").clone(true));
    $('#conDivID').append('</br>');
    $('#conDivID').append("<span class='timeSpan'>" + timeStamp + '</span>');
    $('#conDivID').append('</br>');

    });
    })
    </script>
    <script>
    function sendFunction() {
    var d = new Date()
    var h12 = d.getHours();
    var h24 = d.getHours();
    var m = d.getMinutes();
    var s = d.getSeconds();
    if (s < 10) {
    s = "0" + s
    }
    if (m < 10) {
    m = "0" + m
    }
    if (h12 > 12) {
    h12 = h12 - 12
    }
    if (h12 == 00) {
    h12 = 12
    }

    var timeStamp = h12 + ":" + m + ":" + s + " ";
    if (h24 > 11) {
    timeStamp += "PM";
    } else {
    timeStamp += "AM";
    }

    var userName = document.getElementById("myUserName").value;
    var userinput = document.getElementById("myInput").value;
    var imagesrc = document.getElementById("baseimage");
    var img = $('<img class="img" width=" =100px;" height=" 100px">')
    .attr('src', imagesrc.value);
    var regex = new RegExp("^[A-Za-z0-9]+$");
    if (regex.test(userName)& imagesrc.value =="") {
    $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
    $('#conDivID').append( embedUrls(userinput));
    $('#conDivID').append('</br>');
    $('#conDivID').append("<span class='timeSpan'>" + timeStamp + '</span>');
    $('#conDivID').append('</br>');

    document.getElementById('baseimage').value = "";
    document.getElementById('myInput').value = "";
    document.getElementById("myInput").focus();

    } else if (regex.test(userName)& imagesrc.value !="") {
    $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
    $('#conDivID').append( embedUrls(userinput));
    $('#conDivID').append(%
    Last edited by Max45; Jan 9th, 2019 at 09:24 AM.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: <script> $(function () { var d = new Date() var h

    no idea... what did you change?


    possibly its the img you are setting or trying to set
    Code:
    var img = $('<img width="100px;" height=" 100px">');
    creates an empty image.

    Code:
    $("#conDivID").append($(this).find("img").clone(true));
    looks like it clones it into the conversation div but isnt this image still empty? You dont seem to be sending over which image, id or whatever to use... unless you are grabbing from the dropdown list?
    Last edited by Ecniv; Jan 23rd, 2019 at 07:09 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    65

    Re: <script> $(function () { var d = new Date() var h

    Hi,
    Sorry, because I mixed up with some error in this forum.
    Here the original post
    https://twitter.com/SBC16/status/108...269836288?s=19
    You can check it out it explains every thing.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,455

    Re: <script> $(function () { var d = new Date() var h


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    65

    Re: <script> $(function () { var d = new Date() var h

    Opps. I did it again , this time I mixed up with links. My bad. Here the real link
    https://forums.asp.net/t/2151064.asp...versation+div+
    Really I am so sorry.

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: <script> $(function () { var d = new Date() var h

    Ok.....

    But the other person gave you the code.. havent tested it, but should work.

    Its working by getting the link that the user clicks, finds the first image (img) child it finds and just append via cloning that img into the conv div.

    So which bit doesnt work for you (after you've copied the lot) ?
    The click, the append?
    Are there any errors in the inspection window (right click > inspection) ?
    JQuery sometimes will hide any errors it makes, but the general coding there looks like it will work.
    Did you change anything from the other page?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    65
    The other person gave me the following code and it works successfully.
    But the problem is that I want to change the size of the image from 20 px to 100px

    [CODE]
    <script>
    <div class="dropdown-menu ">

    <a class="dropup-item"
    <button ><img src="https://imgur.com/zLXQ7Ua.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/u82MtgI.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    </div>
    $(function () {
    $("div.dropdown-menu a").click(function () {

    $("#conDivID").append($(this).find("img").clone(true));


    });
    })
    </script>
    [CODE]
    [CODE]
    <script>
    $(function () {
    var d = new Date()
    var h12 = d.getHours();
    var h24 = d.getHours();
    var m = d.getMinutes();
    var s = d.getSeconds();
    if (s < 10) {
    s = "0" + s
    }
    if (m < 10) {
    m = "0" + m
    }
    if (h12 > 12) {
    h12 = h12 - 12
    }
    if (h12 == 00) {
    h12 = 12
    }

    var timeStamp = h12 + ":" + m + ":" + s + " ";
    if (h24 > 11) {
    timeStamp += "PM";
    } else {
    timeStamp += "AM";
    }

    var userName = document.getElementById("myUserName").value;
    var img = $('<img width="100px;" height=" 100px">');
    $("div.dropdown-men
    Last edited by Max45; Jan 25th, 2019 at 06:04 AM.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    65

    Re: <script> $(function () { var d = new Date() var h

    Hi,
    Thank you for your tring to help. I figure out the solution, it is:-
    to set the image's height in CSS style.

    #conDivID img {
    height:100px;
    }

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width