SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic HTML Files

    Is it possible for a webpage to
    write to itself using java or write
    to the hardrive to a text file and
    read it into some txt box fields,

    And how can i do this or does any one
    have some sample code i could look at
    to give me any ideas to do this
    Cheers

  2. #2
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Dynamic HTML Files

    There are several different ways to dynamically update a document on the fly. One of the simplest is to change the text in a textbox:

    Code:
    <html><head>
    <title></title>
    <head>
    <script language="JavaScript">
    function changeText(elm) {
        elm.value = "This text was not here before.";
    }
    </script>
    </head>
    <body>
    <form>
    Click on the textbox to make some text appear.<br><br>
    <input type="text" id="myText" size="50" onclick="changeText(this);">
    </form>
    </body></html>
    Rob Nolan
    Do or do not, there is no try.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Writing to TXT/HTML Files

    This is not wat i meant sry,
    maybe i should of explained it clearer.


    What I need is to write to the actual text file
    or the html itself, so it will insert html code etc,

    is this possible or can i write to another text file on the hard drive and read the text into the html file.

    I know this would be better done using a OOP language, but i have not learnt OOP Programming yet as i only know java consoles (DOS) and know very little of V.Basic.

    What i need is:-

    <form method="POST" action="">

    <p align="center">
    <input type="text" name="TxtCompany" size="3" value="1">

    Company<input type="text" name="T4" size="20">
    Username <input type="text" name="Username" size="20">
    Pass <input type="text" name="BoxPass" size="20">
    Id <input type="text" name="BoxID" size="20">
    <input type="button" value="Login" name="B7"></p>

    <p align="center"><input type="text" name="T16" size="3" value="2">

    Company <input type="text" name="T17" size="20">
    Username <input type="text" name="T18" size="20">
    Pass <input type="text" name="T19" size="20">
    Id <input type="text" name="T20" size="20">
    <input type="button" value="Login" name="B8"></p>

    <p align="center"><input type="text" name="T21" size="3" value="3"> Company <input type="text" name="T22" size="20">
    Username <input type="text" name="T23" size="20">
    Pass <input type="text" name="T24" size="20">
    Id <input type="text" name="T25" size="20">
    <input type="button" value="Login" name="B9"></p>

    <p align="center"><input type="button" value="Add Multiple" name="B6">
    <input type="button" value="Add" name="B3">
    <input type="button" value="Edit" name="B5">
    <input type="button" value="Remove" name="B4"> </p>
    </form>
    <form method="POST" action="">
    </form>


    So i want the user to write there company name username and password etc in text fields and click add it will add a new array etc and allow for the user to add the details and be able to click login when they want there company to log in...

    If Ne one could help me, id be grateful. Also if this is not possible. Could some one point me in the right direction for this in Visual Basic it would be a grate help thanx

  4. #4
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Writing to TXT/HTML Files

    Yes, this is possible. As I said in my original reply, there are many different ways to update a page dynamically. That's why it's called Dynamic HTML!

    There are several methods and properties I think you may want to look into. For starters, look up the createElement Method. This method is used to create new elements for your page. Then, look up the appendChild Method. This one is used to actually put the new elements in the page. Finally, look up the innerHTML property. This property can be used to insert HTML into an element.

    You could have your users fill out the form, and then in your onSubmit() function call createElement, appendChild, and innerHTML to insert the data into your page.

    Example:
    Code:
    function makElm() {
        oElm = document.createElement("div");  
        document.body.appendChild(oElm);
        oElm.innerHTML ="Put some stuff here.";
    
    }
    I didn't test it , but it should lead you in the right direction even if it does not work.
    Rob Nolan
    Do or do not, there is no try.

  5. #5
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Writing to TXT/HTML Files

    I believe you can do this using php/mysql. Even using just xml would probably work.

    http://www.webmasterbase.com/article/228

    That is a series of 4 articals I believe and is well worth looking at to start a db driven content for your web page.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  6. #6
    Spam Can Kill!!! Disk-t's Avatar
    Join Date
    Jul 2001
    Location
    n/a
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php
    if ($submit) {
    $fp = fopen("filetochange.html","a+");
    fputs($fp,$change);
    fclose($fp);
    echo "<a href='http://localhost/filetochange.html'>df</a>";
    }
    ?>
    <form action="updater.php">
    <input type="text" name="change">
    <input type="submit" value="submit" name="submit">
    </form>


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
  •