Help! I need script that allows data submitted in a form on one page, to appear in a scrolling marquee on another. Please include links for any necessary
CSS or JQuery.
Thanks!
Help! I need script that allows data submitted in a form on one page, to appear in a scrolling marquee on another. Please include links for any necessary
CSS or JQuery.
Thanks!
1.html
2.htmlCode:<!DOCTYPE html> <html> <head> </head> <body> <form action="2.html" method="get"> <input type="text" name="userInput1"> <input type="submit"> </form> </body> </html>
Code:<!DOCTYPE html> <html> <head> </head> <body> <marquee><div id="div1"></div></marquee> <script> var query = window.location.search; if (query.substring(0, 1) == '?') { query = query.substring(1); } var data = query.substring(11); document.getElementById('div1').innerHTML = data; </script> </body> </html>
JBest (05-08-2012)
Thanks so much, forgive me, I am new at this. I created the two html pages. Where do I put the php code?I need to be more specific as well. I want the data submitted in the form on this page (see below) to appear on another page in a vertically scrolling marquee, adding each name to the list once submitted.
http://godsmasterdesign.org/EcoPower/Earnings.cgi (I'm going to change it to a html page with no captha code)
Last edited by JBest; 05-08-2012 at 08:53 AM. Reason: Clarifying reply
This doesn't use any php. It's just javascript.
I didn't realise you had access to php. If you want, just say so and I'll do this in php.
Why would you have .cgi pages, but be using php? The file extension for php is .php (or are you swapping from one to the other?). If you want the list to be updated, you're going to need a database (Mysql is good) to store the values. Does your webhost support php/mysql?
JBest (05-08-2012)
Yes! My web host supports php/mysql. Yes Please do it for me in php. Thanks!
1.php
2.phpCode:<!DOCTYPE html> <html> <head> </head> <body> <form action="2.php" method="post"> <input type="text" name="userInput1" /> <input type="submit" name="submit1" /> </form> </body> </html>
The three bits in yellow you need to change to you're database username, database password, and the name of the database you want to store the information in.Code:<!DOCTYPE html> <html> <head> </head> <body> <?php mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("dbName") or die(mysql_error()); if(isset($_POST['submit1'])) { $maxChars = 100; // Put the maximum number of characters you want them to be able to enter here. $userInput = mysql_real_escape_string($_POST['userInput1']); $userInput = substr($userInput, $maxChars); // This the maximum number of characters that a user can submit. Anything after this is simply dropped from their submission $timeObject = time(); $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO userPosts (id, post, timeObject, ip) VALUES('0', '$userInput', '$timeObject', '$ip') "); $result = mysql_query("SELECT * FROM userPosts ORDER BY timeObject"); echo '<marquee direction="up" loop="true" scrollamount="2">'; while($row = mysql_fetch_array( $result )) { echo $row['post']; echo '<br />'; } echo '</marquee>'; } ?> </body> </html>
After that, open up phpmyadmin (should be installed on your webhost) navigate to the database you've made, then run this sql code under the sql tab.
The two numbers in red should match up. This the maximim(?spelling?) number of characters you want users to be able to post. Anything after that number will be deleted.Code:CREATE TABLE userPosts( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), post VARCHAR(100), timeObject VARCHAR(14), ip VARCHAR(20))
If you've got any questions, don't hesatate to ask.
Last edited by keyboard; 05-09-2012 at 01:59 AM.
JBest (05-09-2012)
One more thing;
The <marquee> tag is only supported by IE. In all the other browsers, it won't do anything...
Bookmarks