+ Reply to Thread
Results 1 to 3 of 3
Like Tree2Likes
  • 1 Post By james70
  • 1 Post By callumacrae

Thread: I need help with java script codeing

  1. #1
    james70 is offline x10Hosting Member james70 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    6

    I need help with java script codeing

    I want to extract some info from one page and insert it into another page.

    I have a section of a page that looks like this:

    HTML Code:
      <!-- start content -->
      <div id="content">
       <div class="post">
        <h1 class="title"><p>Title</p></h1>
        <div class="entry">
              My Text........
        </div
       </div>
      </div>
      <!-- end content -->
    How do I extract and write the " My Text......" to another page?
    Last edited by callumacrae; 12-27-2011 at 07:33 AM. Reason: Added [html] tag.
    karimirt47 likes this.

  2. #2
    ellescuba27 is online now x10 Sophmore ellescuba27 is an unknown quantity at this point
    Join Date
    Sep 2011
    Posts
    151

    Re: I need help with java script codeing

    Hi james70!
    There are a few ways to pass the information to the other page, I am assuming that's what you want.
    First, we want to get what's inside that <div>. I would do this by giving the <div> an ID:
    HTML Code:
    <div id="texttoget" class="entry">
    My Text...
    </div>
    And with Javascript, get the text inside using innerHTML. Let's put it in a variable called thetext .
    Code:
    var thetext = document.getElementById("texttoget").innerHTML;
    Now we decide how to pass it. My personal favourite is using window.name .
    Code:
    window.name = thetext;
    That way the window's name will be what is inside the <div>. When you get to the other page, just use
    Code:
    var thetext2 = window.name;
    Now the other page has what was in that <div> in the variable thetext2 . Make sure you clear window.name though (the default is "view").

    Another way to do it is to use the address bar at the top of the page. There is a tutorial on how to do this at HTMLGoodies (he'll probably explain it better):
    http://www.htmlgoodies.com/beyond/ja...le-Passing.htm

    So now you know! Hope that helps!
    Last edited by callumacrae; 12-27-2011 at 07:34 AM.

  3. #3
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: I need help with java script codeing

    I added [html] and [code] tags to both of your posts - please use them in the future.

    Adding it to the window object will not mean that you can access it across pages, you want to set a cookie or something.


    I'm not really sure what you're asking - could you give us a context and example, please? Also, are you using AJAX at all?
    dinomirt96 likes this.
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

+ Reply to Thread

Similar Threads

  1. Script. (java?)
    By jtaah in forum Free Hosting
    Replies: 1
    Last Post: 12-21-2009, 08:21 PM
  2. java script
    By swhybd in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 10-21-2009, 12:57 PM
  3. java script
    By swhybd in forum Free Hosting
    Replies: 2
    Last Post: 10-19-2009, 10:25 AM
  4. Can I have this java script in my web?
    By ElectroGadget in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 08-26-2008, 09:49 AM
  5. java script help
    By sunils in forum Programming Help
    Replies: 4
    Last Post: 06-02-2008, 01:16 PM

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
x10hosting free hosting for the masses
dedicated servers