Welcome to the IMTalk - Internet Marketing & SEO Forum.
  • Login:
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 26
  1. #1
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts

    Question [HELP] Anyone can help me how to prog this using .js/javascript code

    hello guys,, i know some of you guys here can help me how to code this using .js/javascript ..i have a project usind this sample below

    when i type my name in the text area (name ) then click submit it will show some emotions like
    * sad (name)
    * Happy (name)
    * etc
    with the interval of 2 to 5 seconds per emotions
    then after that the "Thank you message"
    Please help me!

  2. #2
    AaronLuke's Avatar
    AaronLuke is offline IM & SEO Weak Jaw AaronLuke will become famous soon enough AaronLuke will become famous soon enough
    Join Date
    Aug 2011
    Posts
    140
    Thanks Given
    22
    Thanked 114 Times in 33 Posts
    Hi, this should work...

    <html>
    <head>
    <title>Javascript - Emotions</title>
    <script type="text/javascript">
    function emotions()
    {
    var r = Math.random();

    if (r < 0.2)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Happy ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Jealous ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Scared ' +document.getElementById('name').value",9000);
    }
    else if(r < 0.4)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Envious ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Joyful ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Fearful ' +document.getElementById('name').value",9000);
    }
    else if(r < 0.6)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Calm ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Serene ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Caring ' +document.getElementById('name').value",9000);
    }
    else if(r < 0.8)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Alert ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Excited ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Nervous ' +document.getElementById('name').value",9000);
    }
    else
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Dynamic ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Bold ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Daring ' +document.getElementById('name').value",9000);
    }
    var t4=setTimeout("document.getElementById('thankyou') .innerHTML='Thank You'",12000);
    }
    function clearText()
    {
    document.getElementById('name').value='';
    document.getElementById('emotion1').innerHTML='';
    document.getElementById('emotion2').innerHTML='';
    document.getElementById('emotion3').innerHTML='';
    document.getElementById('thankyou').innerHTML='';
    }
    </script>
    </head>
    <body>
    <input type="text" id="name">
    <input type="button" value="Submit" onClick="emotions()">
    <input type="button" value="Clear" onClick="clearText()"><br />
    <p id="emotion1"></p>
    <p id="emotion2"></p>
    <p id="emotion3"></p>
    <p style="padding-left:2em" id="thankyou"></p>
    </body>
    </html>
    Last edited by AaronLuke; 02-17-2012 at 04:35 AM.

  3. The Following 2 Users Say Thank You to AaronLuke For This Useful Post:


  4. #3
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts
    wow..its working ^_^

    thank you very much for this code...i will message you if i have problem with this..
    another question...how about i want to clear the text area and all the emotions \?
    Last edited by tinamoran; 02-16-2012 at 02:40 AM. Reason: need question

  5. #4
    AaronLuke's Avatar
    AaronLuke is offline IM & SEO Weak Jaw AaronLuke will become famous soon enough AaronLuke will become famous soon enough
    Join Date
    Aug 2011
    Posts
    140
    Thanks Given
    22
    Thanked 114 Times in 33 Posts
    No problem. I edited my post and added a clear button.

  6. The Following User Says Thank You to AaronLuke For This Useful Post:


  7. #5
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts
    how about the random post of emotions?it is possible?or even clickable?and an alert message that when the user refresh or close it and the emotions are not totally finish, the alert will show and remind if the user want to cancel or continue until it finish...is that possible?
    thanks in advance.. ^_^
    Last edited by tinamoran; 02-16-2012 at 06:45 AM. Reason: missing

  8. #6
    AaronLuke's Avatar
    AaronLuke is offline IM & SEO Weak Jaw AaronLuke will become famous soon enough AaronLuke will become famous soon enough
    Join Date
    Aug 2011
    Posts
    140
    Thanks Given
    22
    Thanked 114 Times in 33 Posts
    I edited with an example of random emotions being chosen. I haven't done anything like the other part but all of that looks very possible.

  9. #7
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts
    Quote Originally Posted by AaronLuke View Post
    I edited with an example of random emotions being chosen. I haven't done anything like the other part but all of that looks very possible.
    why is that when i hit enter it auto clear? hmmm
    thank you

  10. #8
    AaronLuke's Avatar
    AaronLuke is offline IM & SEO Weak Jaw AaronLuke will become famous soon enough AaronLuke will become famous soon enough
    Join Date
    Aug 2011
    Posts
    140
    Thanks Given
    22
    Thanked 114 Times in 33 Posts
    By default when you press enter in a text field of a form, it is the same as pressing the submit button in a form to submit data which usually submits the data and refreshes the page or goes to a new page.

    Since this isn't really a form you can take out the <form> and </form> tags and that should prevent the enter button from submitting/refreshing the page in the text field. I will edit my post.

  11. The Following User Says Thank You to AaronLuke For This Useful Post:


  12. #9
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts
    thank you..sorry for many asking question..another one is,,it is also possible to give an alert when the user accidentally hit the enter/submit button without any words in the text area?

  13. #10
    AaronLuke's Avatar
    AaronLuke is offline IM & SEO Weak Jaw AaronLuke will become famous soon enough AaronLuke will become famous soon enough
    Join Date
    Aug 2011
    Posts
    140
    Thanks Given
    22
    Thanked 114 Times in 33 Posts
    No problem and yes you can do that. The code should be at the beginning of the emotions function and something like...

    if(document.getElementById('name').value='')
    {
    //alert box code
    }
    else
    {
    //the rest of the code in the emotions function
    }

    I will try later.

  14. #11
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts
    not working..

  15. #12
    AaronLuke's Avatar
    AaronLuke is offline IM & SEO Weak Jaw AaronLuke will become famous soon enough AaronLuke will become famous soon enough
    Join Date
    Aug 2011
    Posts
    140
    Thanks Given
    22
    Thanked 114 Times in 33 Posts
    I forgot that since it's an if statement, there has to be 2 equal signs. So it should actually be if(document.getElementById('name').value=='')

  16. #13
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts
    Quote Originally Posted by AaronLuke View Post
    I forgot that since it's an if statement, there has to be 2 equal signs. So it should actually be if(document.getElementById('name').value=='')
    ok i will try..and also i did some debugging then when i hit the enter it also post the emotions

    still not working..

    sorry for the multiple question hope you understand

  17. #14
    bencurnow's Avatar
    bencurnow is offline IM & SEO Small Talker bencurnow has a spectacular aura about bencurnow has a spectacular aura about
    Join Date
    Jan 2012
    Location
    England
    Posts
    561
    Thanks Given
    120
    Thanked 137 Times in 119 Posts
    Quote Originally Posted by AaronLuke View Post
    No problem and yes you can do that. The code should be at the beginning of the emotions function and something like...

    if(document.getElementById('name').value=='')
    {
    //alert box code
    }
    else
    {
    //the rest of the code in the emotions function
    }

    I will try later.
    In the place where AaronLuke has put //alert box code you need to change that to the alert function you would like. For instance put alert("Please Type Something Into The Name Field");


    This would mean the complete code is

    HTML Code:
    <html>
    <head>
    <title>Javascript - Emotions</title>
    <script type="text/javascript">
    function emotions()
    {	
    var r = Math.random();
    
    if(document.getElementById('name').value=='')
    {
    // Alert Box Code
    alert("Please Type Something Into The Name Field");
    }
    else
    {
    //the rest of the code in the emotions function
    
    if (r < 0.2)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Happy ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Jealous ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Scared ' +document.getElementById('name').value",9000);
    }
    else if(r < 0.4)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Envious ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Joyful ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Fearful ' +document.getElementById('name').value",9000);
    }
    else if(r < 0.6)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Calm ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Serene ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Caring ' +document.getElementById('name').value",9000);
    }
    else if(r < 0.8)
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Alert ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Excited ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Nervous ' +document.getElementById('name').value",9000);
    }
    else
    {
    var t1=setTimeout("document.getElementById('emotion1') .innerHTML='Dynamic ' +document.getElementById('name').value",3000);
    var t2=setTimeout("document.getElementById('emotion2') .innerHTML='Bold ' +document.getElementById('name').value",6000);
    var t3=setTimeout("document.getElementById('emotion3') .innerHTML='Daring ' +document.getElementById('name').value",9000);
    }
    var t4=setTimeout("document.getElementById('thankyou') .innerHTML='Thank You'",12000);
    }
    function clearText()
    {
    document.getElementById('name').value='';
    document.getElementById('emotion1').innerHTML='';
    document.getElementById('emotion2').innerHTML='';
    document.getElementById('emotion3').innerHTML='';
    document.getElementById('thankyou').innerHTML='';
    }
    }
    </script>
    </head>
    <body>
    Name:<input type="text" id="name"></br></br>
    <input type="button" value="Submit" onClick="emotions()">
    <input type="button" value="Clear" onClick="clearText()"><br />
    <p id="emotion1"></p>
    <p id="emotion2"></p>
    <p id="emotion3"></p>
    <p style="padding-left:2em" id="thankyou"></p>
    </body>
    </html>

  18. The Following User Says Thank You to bencurnow For This Useful Post:


  19. #15
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts

    Question ...

    once i click the 'clear' nothings happen?

    it is also possible to create like this once

    i think this is less line of codes..




    if not text input alert message will show and
    once enter text the 'name' is Happy will show after the delay..

    please help me..

  20. #16
    bencurnow's Avatar
    bencurnow is offline IM & SEO Small Talker bencurnow has a spectacular aura about bencurnow has a spectacular aura about
    Join Date
    Jan 2012
    Location
    England
    Posts
    561
    Thanks Given
    120
    Thanked 137 Times in 119 Posts
    What do you mean by etc.

  21. #17
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts

    ..

    etc means more sentence..

    i want to input more sentence like

    'name' is happy
    'name' is sad
    'name' is unlucky
    'name' is weird
    'name' is neird
    'name' is cool
    'name' is nice
    'name' is angry
    'name' is confuse
    'name' is dizzy

    please help me

  22. #18
    bencurnow's Avatar
    bencurnow is offline IM & SEO Small Talker bencurnow has a spectacular aura about bencurnow has a spectacular aura about
    Join Date
    Jan 2012
    Location
    England
    Posts
    561
    Thanks Given
    120
    Thanked 137 Times in 119 Posts
    Do you want it to say all of the name is ... and then say I love name very much

    Like this:
    'name' is happy
    'name' is sad
    'name' is unlucky
    'name' is weird
    'name' is neird
    'name' is cool
    'name' is nice
    'name' is angry
    'name' is confuse
    'name' is dizzy
    I love name very much

    or do 1 name is ... and then 1 I love name very much and repeat
    Like this
    'name' is happy
    I love name very much
    'name' is sad
    I love name very much
    'name' is unlucky
    I love name very much
    'name' is weird
    I love name very much
    'name' is neird
    I love name very much
    'name' is cool
    I love name very much
    'name' is nice
    I love name very much
    'name' is angry
    I love name very much
    'name' is confuse
    I love name very much
    'name' is dizzy
    I love name very much

    ?

  23. #19
    tinamoran's Avatar
    tinamoran is offline IM & SEO Mumbler tinamoran will become famous soon enough tinamoran will become famous soon enough
    Join Date
    Jul 2011
    Location
    computer world
    Posts
    281
    Thanks Given
    9
    Thanked 93 Times in 54 Posts

    ..

    the 'name' is the value of the text area
    and the default text
    "is happy"
    example i enter " tina " in the textfield
    then it will show

    tina is happy

    get it?

    sorry if im not to explain very well ,hope you understand

  24. #20
    bencurnow's Avatar
    bencurnow is offline IM & SEO Small Talker bencurnow has a spectacular aura about bencurnow has a spectacular aura about
    Join Date
    Jan 2012
    Location
    England
    Posts
    561
    Thanks Given
    120
    Thanked 137 Times in 119 Posts
    Sorry, so when is it supposed to show all the other emotions?


 

Similar Threads

  1. [lookin for] best PPV program for many sites (one code)
    By stronywwwlublin in forum Affiliate, CPC, CPA Programs
    Replies: 0
    Last Post: 12-10-2011, 02:04 PM
  2. Blocking Spam With Javascript
    By Phil Tanny in forum Programming, Scripting, Database, Testing, Debugging...
    Replies: 1
    Last Post: 10-08-2011, 01:33 AM
  3. How to pass a PHP variable to Javascript
    By Trek in forum Programming, Scripting, Database, Testing, Debugging...
    Replies: 5
    Last Post: 09-02-2011, 11:19 AM
  4. Replies: 10
    Last Post: 05-04-2011, 02:57 PM
  5. I need a Pop Up Silder HTML Code
    By seobunny in forum Website Planning, Design & Development
    Replies: 1
    Last Post: 12-15-2010, 02:21 AM

Tags for this Thread

Posting Permissions

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