|
-
Aug 13th, 2001, 12:41 PM
#1
Thread Starter
Lively Member
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.
-
Aug 13th, 2001, 04:09 PM
#2
Fanatic Member
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.
-
Aug 14th, 2001, 08:32 AM
#3
Thread Starter
Lively Member
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".
-
Aug 14th, 2001, 10:18 AM
#4
the only way to preserve it is if it was being loaded from the database. or write another cookie to preserve it.
-
Aug 14th, 2001, 10:24 AM
#5
Fanatic Member
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>
-
Aug 14th, 2001, 10:28 AM
#6
Fanatic Member
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.
-
Aug 15th, 2001, 08:44 AM
#7
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|