Jump to content
mboehler3

Displaying user-submitted text on page

Recommended Posts

I've been searching through Google to find a solution but I think the problem is, I can't explain this very well. So here goes...I have a "bumper sticker" section of my website that has a form-type submission box. In the submission box, a user can type a suggestive bumper sticker phrase.What I'm trying to accomplish is this: The user hits "submit" on the form, and immediately see's their text on a "bumper sticker" (most likely just a <div> tag with a background-color, height and width).I've seen this before on webpages, including w3schools. It's kinda similar to the way you can edit CSS on w3schools and immediately see your changes on the same page.I don't know if this is a difficult request or something where I can just find a script online. Either way, your recommendations will be very helpful.Thanks!

Share this post


Link to post
Share on other sites

well you dont need to have a form submit. you can just create the textbox with an input button and when you click the button, you take the contents of the input and place it the div tag all through JS. Something like this:

<div id="someDiv"></div><textarea id="bumper"></textarea><input type="button" id="button" />document.getElementById('button').onclick = function () {var bumper = document.getElementById('bumper').value;document.getElementById('someDiv').innerHTML = bumper;}

Share this post


Link to post
Share on other sites

Do you want this thing to be permanent, or it's just not there the next time they visit?

Share this post


Link to post
Share on other sites
Do you want this thing to be permanent, or it's just not there the next time they visit?
I'd like it to me temporary, so when they start another session on my page, their previous bumper sticker no longer remains.

Share this post


Link to post
Share on other sites
Then if Dave's technique works ok, you should be good.
Depends on what mboehler3 means by "start another session"If "session" means something like the PHP $_SESSION then Dave's technique won't work. Dave's technique will only last as long as the page is not reloaded.

Share this post


Link to post
Share on other sites
Depends on what mboehler3 means by "start another session"If "session" means something like the PHP $_SESSION then Dave's technique won't work. Dave's technique will only last as long as the page is not reloaded.
To clarify, I meant when a user goes to the site, plays with the bumpersticker, leaves the site (closes their browser). Then later in the hour/day/week they return.

Share this post


Link to post
Share on other sites
To clarify, I meant when a user goes to the site, plays with the bumpersticker, leaves the site (closes their browser). Then later in the hour/day/week they return.
Leaving the site and closing the browser can be two very different things.Leaving the site can mean simply hitting Refresh or clicking a link. In these cases, a PHP session would retain the bumper sticker, but Dave's method would not.Closing the browser would terminate the PHP session.

Share this post


Link to post
Share on other sites

Setting a cookie that expires after a certain time limit and refreshing it every time the user loads a page from your site before the cookie expires would work, too.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...