Results 1 to 4 of 4

Thread: Display text with no reloading

  1. #1
    Join Date
    Jul 2008
    Posts
    65
    Thanks
    42
    Thanked 0 Times in 0 Posts

    Default Display text with no reloading

    I'm a newbie to JavaScript more used to PHP and other such languages, so when I found myself in a situation that required JavaScript I was stuck. I have a onclick() event on my page wich when it's clicked i want it to display some text somewhere on the page WITHOUT THE ENTIRE PAGE RELOADING. I'd be really gratfull if anyone could offer me some help.

    Thanks

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Here you go:
    Code:
    <script type="text/javascript">
    function putText(el,text){
    document.getElementById(el).innerHTML=text;
    }
    </script>
    <div id="div1"></div><div id="div2"></div>
    <input type="button" onClick="putText('div1','Div1 here... Nothing special...');" value="Change Div1"/>
    <input type="button" onClick="putText('div2','Div2 here... Nothing special...  Just kidding, you know me... :)');" value="Change Div1"/>
    The first highlighted part is for the div you want to change, and the next is for the text.
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    hosdank (08-01-2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    65
    Thanks
    42
    Thanked 0 Times in 0 Posts

    Default

    Thanks SO much!!!

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Anytime, it was very simple. Just 3 codes of line in the js, and 1 code of line in the js that is important.
    Last edited by Nile; 07-30-2008 at 01:00 AM.
    Jeremy | jfein.net

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
  •