Results 1 to 7 of 7

Thread: DTHML Question

  1. #1

    Thread Starter
    Lively Member Nator's Avatar
    Join Date
    Nov 1999
    Location
    East Larryville, GA
    Posts
    80

    DTHML Question

    This may be a dumb question, but how do you allow a user to change the content on a page?

    I have a page that uses data from a cookie. I want the user to be able to edit the cookie-based data if necessary, but I don't want to have to reload the ASP page (fewer DB calls, etc.), just change the text on the page that was originally created from the cookie.

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Depending on the browser the page can be changed through JavaScript...If you got a little more specific it would make things a bit clearer to see what you mean.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3

    Thread Starter
    Lively Member Nator's Avatar
    Join Date
    Nov 1999
    Location
    East Larryville, GA
    Posts
    80
    Even though this doesn't use cookies, I think this I can take it from there. Say I had something like this:

    <HTML>
    <SCRIPT language="javascript">
    function WrtieNewStuff()
    {
    write some new text
    }
    </SCRIPT>
    <BODY>
    The old stuff. <a href='javascript:WriteNewStuff();'>Click to write new stuff</a>
    </body>
    </HTML>


    When the user clicked the link, the link would call the WriteNewStuff function and write some text or HTML. How do I preserve what is already on the page (ie "The old stuff") where the page reads "The old stuff. The new stuff".

  4. #4
    scoutt
    Guest
    the only way to preserve it is if it was being loaded from the database. or write another cookie to preserve it.

  5. #5
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    You can store the old text in a variable:
    Code:
    ...
    
    <script LANGUAGE = "JavaScript">
    var oldStuff;
    
    function writeNewText(strNewText){
    
    oldStuff = document.all.varText.innerText;
    document.all.varText.innerText = strNewText;
    alert(oldStuff + ' ' + '\nWas saved!');
    
    }
    
    
    </script>
    
    ...
    
    <p ID = "varText">This text is old</p>
    
    ...
    
    <a HREF = "JavaScript:writeNewText('This text is new');">Write new text</a>
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  6. #6
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Of course, once the variable goes out of scope, you lose any saved values. To persist the values you'd have to use cookies or a db.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  7. #7

    Thread Starter
    Lively Member Nator's Avatar
    Join Date
    Nov 1999
    Location
    East Larryville, GA
    Posts
    80
    Exactly what I was looking for. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width