SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Non-Member
    Join Date
    Mar 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy PLEASE HELP ME!! -( innerHTML

    i have a code here
    Code:
    <html>
    <head>
    <title>Javascript - Emotions</title>
    <script type="text/javascript">
    function emotions()
    {
    var t1=setTimeout("document.getElementById('emotion1' ) .innerHTML='Happy'  +document.getElementById('name').value",1000);
    var t4=setTimeout("document.getElementById('thankyou') .innerHTML='Thank You'",2000);
    }
    function clearText()
    {
    document.getElementById('name').value='';
    document.getElementById('emotion1').innerHTML='';
    document.getElementById('thankyou').innerHTML='';
    }
    </script>
    </head>
    <body>
    <form>
    <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>
    </form>
    </body>
    </html>
    is this possible to add another emotions here
    Code:
    ("document.getElementById('emotion1' ) .innerHTML='Happy'
    ? because i like to lessen my work..example is
    Code:
    .innerHTML='Happy' 'Sad'
    ? i try this but no lucky at all
    Code:
    var t1=setTimeout("document.getElementById('emotion1' ) .innerHTML='Happy'  +document.getElementById('name').value",1000);
    creating many lines of codes looks my notepad like scratch paper .. please help me

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,337
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    If I understand your question correctly, this is what you want:
    Code:
    <html>
    <head>
    <title>Javascript - Emotions</title>
    <script type="text/javascript">
    function emotions()
    {
    var t1=setTimeout("document.getElementById('emotion1' ) .innerHTML='Happy '  +document.getElementById('name').value",1000);
    var t2=setTimeout("document.getElementById('emotion2' ) .innerHTML='Why are you Sad '  +document.getElementById('name').value + '?'",1000);
    var t4=setTimeout("document.getElementById('thankyou') .innerHTML='Thank You'",2000);
    }
    function clearText()
    {
    document.getElementById('name').value='';
    document.getElementById('emotion1').innerHTML='';
    document.getElementById('thankyou').innerHTML='';
    }
    </script>
    </head>
    <body>
    <form>
    <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>
    </form>
    </body>
    </html>
    I simply:
    1. Copied the line that began "t1"
    2. Pasted it as a new line and modified the TWO PLACES the numeral '1' appeared with a '2'
    3. Then changed the text (as desired)



    It is important that there are enough <p id="emotionX"> for the number of new emotions you create.
    Last edited by ParkinT; Mar 5, 2012 at 13:23.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    Non-Member
    Join Date
    Mar 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i only want to add another emotions here
    Code:
    .innerHTML='Happy'
    w/o creating new lines of codes..

  4. #4
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,337
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    What happens if you replace the word 'Happy' with another word? That will change the emotion.
    Code:
    var t1=setTimeout("document.getElementById('emotion1' ) .innerHTML='Frustrated '  +document.getElementById('name').value",1000);
    To add a new emotion you must add ONE line of code (for each new emotion)
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  5. #5
    Non-Member
    Join Date
    Mar 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ..

    ok..i though its possible to add another emotions without creating new lines of code..thank you..
    maybe i need to create new one..and hope this one can easy to you to help me.

    i created pics so that you will understand what i mean..thanks in advance help

    new-proj.JPG

    this one is using 1 webpage only i dont know is this using javascript to create next slide menu..please help me again..

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    It's likely you'd have to use some sort of library or organized library in order to shorten what you'd have to write to that. ParkinT did a good job of explaining the correct situation/solution .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com


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
  •