Results 1 to 2 of 2

Thread: How to modify cmarquee2 so a textArea can be accessed to enter scrolling content

  1. #1
    Join Date
    May 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to modify cmarquee2 so a textArea can be accessed to enter scrolling content

    1) Script Title: Cross Browser marquee II

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/cmarquee2.htm
    3) Describe problem: I'm wondering how this script can be modified so that ADD CONTENT HERE can be a textArea on a web page where a web page visitor can enter content, submit and see the scrolling content in the marquee container. I currently have a basic TextArea coding successfully working where text is entered, submitted and appears on the same html page (via php):

    HTML Code:
    Comments:<br>
    <textarea name="comments" id="comments" minlength="20" maxlength="120" rows="14" cols="130" form="myForm">
    Hey... say something!
    </textarea><br>
    <form action="/textArea.php" target="processForm" method="post" id="myForm">
    <input type="submit" value="Submit">
    </form>
    <br><br>
    <iframe name="processForm" width="75%" height="70%">
    and the php:

    Code:
    <?php
    echo $_POST['comments'];
    ?>
    but can't figure out how to integrate it with your cmarquee2 code.

    Any guidance is greatly appreciated.
    Last edited by keyboard; 05-26-2021 at 03:53 AM.

  2. #2
    Join Date
    Mar 2011
    Posts
    2,170
    Thanks
    60
    Thanked 120 Times in 116 Posts
    Blog Entries
    4

    Default

    Hey chrisjchrisj, and welcome to the forums! Apologies it took a while to respond.
    Can you explain a bit regarding where the user's input is coming from? Is the user entering text into the form and then it is shown to them straight away? Or is it uploaded to a storage system (e.g., a database).
    If it's being displayed straight away, you can use pure javascript (no PHP) to achieve what you're describing.

    e.g., If you have the form and marquee HTML setup as follows
    HTML Code:
    <div id="marqueecontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">
        <div id="vmarquee" style="position: absolute; width: 98%;">
            <h4>Your scroller contents</h4>
        </div>
    </div>
    
    <form action="#" id="myForm">
        Comments:<br />
        <textarea name="comments" id="comments" minlength="20" maxlength="120" rows="14" cols="130" form="myForm">Hey... say something!</textarea>
        <br />
        <input type="submit" value="Submit">
    </form>
    You could use the following javascript code (you'll also need the Cross Browser marquee II script included)
    HTML Code:
    <script type="text/javascript">
        //Bind an event to run after the page is ready, so that we can interact with the DOM elements on the page.
        document.addEventListener("DOMContentLoaded", () => {
            //Get a reference to the form and the marquee DOM elements.
            const form = document.getElementById("myForm");
            const marquee = document.getElementById("vmarquee");
            
            //Bind an event to trigger when the form is submitted.
            form.addEventListener("submit", event => {
                //Set the marquee's text to the contents of the input inside the form named "comments".
                marquee.textContent = form.elements["comments"].value;
                
                //Prevent the form from submitting.
                return false;
            });
        })
    </script>

Similar Threads

  1. Resolved textarea using ENTER
    By auriaks in forum PHP
    Replies: 46
    Last Post: 01-11-2010, 02:43 AM
  2. Access and Modify a databases content...
    By remp in forum MySQL and other databases
    Replies: 1
    Last Post: 07-29-2008, 12:50 AM
  3. modify Drop-in content Box
    By terkini in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 12-20-2006, 09:20 AM
  4. How do I modify the Tab Content to my Choice?
    By fakshon in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 07-25-2006, 08:30 AM
  5. How to modify Tab Content Script?
    By Wildfire563 in forum Dynamic Drive scripts help
    Replies: 9
    Last Post: 06-29-2005, 02:56 AM

Bookmarks

Posting Permissions

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