#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    New Hampshire
    Posts
    116
    Rep Power
    11

    HTML javascript append


    Is there a way to append an html doc with js. The document.write overwrites the entire doc, I just want to append. Having said that, how about embedding an html doc within an html doc, frames seem limited in how you can align the docs. What I would like to do embed an html doc within a div tag.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Buenos Aires, Argentina
    Posts
    74
    Rep Power
    11
    About the first one, I don't now about it!
    The second one, I have a possible solution in other thread
    In that case, the embedded page was dynamically generated and so the SRC on the IFRAME has a jsp on it, but you can use a common one too.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    New Hampshire
    Posts
    116
    Rep Power
    11

    SUM: HTML javascript append


    Thanks for the tip, it wasn't exacty what I needed, but it got me thinking and I came up with the solution. Simple, but it took many posts to three diifferent lists with little insight. For anyone interested this what I came up with.

    This is the embeded php, I considered embedding HTML, but only because I was running out of ideas. What I was trying to accomplish was to update the php without reloading the entire page.

    <div class="info">
    <embed style ="position: absolute" name="info" src="files/countryinfo.php?pID=0" width="237px" height="291px" type="image/svg+xml">
    </div>

    This is the js to reset the source with an onclick event, supplying it with a new variable, querrying the database.

    function click(idsel, map) {
    theInfo="files/countryinfo.php?pID="+idsel;
    Info=window.document.embeds[3];
    Info.setSrc(theInfo);
    }

    This is my php file that writes an SVG doc (XML). Which is now updated perfectly without reloading the entire page. This file is simple, but now that it works, I can build elaborate, dynamic pages.

    <?print('<?xml version="1.0" encoding="iso-8859-1"?>');?>
    <svg id="map" width="237" height="291" viewBox="0 0 535 507" zoomAndPan="disable" preserveAspectRatio="xMinYMin">
    <desc>Information</desc>

    <?php
    //open the connection
    $id=$HTTP_GET_VARS["pID"];
    $conn = mysql_connect("localhost");
    //pick the database to use
    mysql_select_db("states", $conn);
    //create the SQL statement
    $sql = "select name, area, sub_region, pop2000, hse_units from states where objectid ='$id'";
    $result = mysql_query($sql, $conn) or die(mysql_error());
    while ($newArray = mysql_fetch_array($result)) {
    //give a new name to the fields
    $sname = $newArray['sub_region'];
    $COUNTRYNAME = $newArray['name'];
    $MANAGER = $newArray['sub_region'];
    $PHONE = $newArray['hse_units'];
    }
    mysql_close($conn);
    ?>

    <text x="10" y="40" id="title"
    style ="font-family:Arial, Geneva, Helvitica, sans-serif;
    font-size:20pt;font-weight:bold;color:white;alignment-baseline:baseline">
    <?=$COUNTRYNAME?>
    </text>
    <text x="10" y="85" id="title"
    style ="font-family:Arial, Geneva, Helvitica, sans-serif;
    font-size:20pt;font-weight:bold;color:white;alignment-baseline:baseline">
    Manager: <?=$sname?>
    </text>
    <text x="10" y="120" id="title"
    style ="font-family:Arial, Geneva, Helvitica, sans-serif;
    font-size:20pt;font-weight:bold;color:white;alignment-baseline:baseline">
    Phone: <?=$PHONE?>
    </text>
    </svg>

IMN logo majestic logo threadwatch logo seochat tools logo