Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: calling a specific div on an external page

  1. #1
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default calling a specific div on an external page

    Dynamic Ajax Content

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    I have 20 tables that are rather small. Rather than having 20 pages, I'd much rather have 1 page and 20 divisions.
    If it is possible, how would I go about calling a specific table on that single page?

    If not possible, could one of you fine scholars of scripting make it possible?
    I really do not want 10,000 little files to keep track of.

    Thanks.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There are two options for this:

    1. Use one of the "tabs" scripts offered here. But not one with Ajax. The entire purpose of Ajax is to load multiple external files, so that's something you'd want to avoid in this case.

    2. Use a serverside language like PHP (or ASP, CGI, Perl, etc.) to selectively display one item or another based on a variable in the URL (like page.php?item=5).

    (1) is a little smoother arguably, but it relies on Javascript so it won't necessarily work for everyone (some people might have JS disabled) and search engines could have difficulty seeing it, potentially. (2) requires the ability to use a serverside language, but it would then work in every case because it would be one file on the server but actually effectively serving 20 different pages-- to the user's computer, it would be like 20 separate pages. So it's your choice about which one sounds better. (1) is probably harder to code than (2) [assuming you know PHP and JS equally well], but because there are scripts already available for (1) they're about equal then.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That script doesn't really do that, try jQuery .load():

    http://home.comcast.net/~jscheuer1/s...es-jq/demo.htm

    demo.htm:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
    	$('#tableselect').change(function(){
    		$('#resultarea').load('table.htm #table_' + this.options.selectedIndex);
    	}).trigger('change');
    });
    </script>
    </head>
    <body>
    Choose Table: <select id="tableselect">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
    </select>
    <div id="resultarea"></div>
    </body>
    </html>
    table.htm:
    Code:
    <div>
    <table id="table_0">
    <tr>
    <td>Table #1</td>
    </tr>
    </table>
    <table id="table_1">
    <tr>
    <td>Table #2</td>
    </tr>
    </table>
    <table id="table_2">
    <tr>
    <td>Table #3</td>
    </tr>
    </table>
    <table id="table_3">
    <tr>
    <td>Table #4</td>
    </tr>
    </table>
    <table id="table_4">
    <tr>
    <td>Table #5</td>
    </tr>
    </table>
    <table id="table_5">
    <tr>
    <td>Table #6</td>
    </tr>
    </table>
    <table id="table_6">
    <tr>
    <td>Table #7</td>
    </tr>
    </table>
    <table id="table_7">
    <tr>
    <td>Table #8</td>
    </tr>
    </table>
    <table id="table_8">
    <tr>
    <td>Table #9</td>
    </tr>
    </table>
    <table id="table_9">
    <tr>
    <td>Table #10</td>
    </tr>
    </table>
    </div>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the info.

    http://1littleworld.net/test/test1.html

    Someone else wrote this and I like it. Problem is, it won't work locally for me.
    Due to the nature of the ajax part I guess, it needs to be on a server.
    No big deal. But I would like to see it work locally as well.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    See my previous post in this thread.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks John.
    But I need that to function from a button link. Your version works locally. Which is what I need.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Show me the button.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Nothing more than the standard button tag for html.
    Code:
    <button>button button who's got the button?</button>

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, but how do I know which table it's supposed to summon? Is there one button for each table?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Yes. Button1 calls table1 and button2 calls table2 and so on.

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
  •