Jump to content

Displaying user-submitted text on page


mboehler3
 Share

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!

Link to comment
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;}

Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...