Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ General Web Design _ HTML Script for Placing Text

Posted by: Tom G Apr 20 2019, 03:44 PM

Hey.... is there basic html script to allow the following?:

In our church app, we can use basic html. What I am trying to do, is have the user type within a "fill in the blank" field, but I want what they typed to also appear way down the page in another paragraph, targeting a specific spot in a sentence in the paragraph down the page. I need to get this done today if it's possible. It's for our Easter service tomorrow. Our pastor just had this idea... hence the urgency!

Thanks for any input!!

Tom

Posted by: Christian J Apr 21 2019, 03:47 AM

Do you want to allow anyone to write on the page, and do you want the result to be saved and stay visible to any visitor? Then you need a server-side script (like PHP), and it's not a quick task.

But if you only want each user to see the result in his own browser, you can do it relatively fast with java script:

CODE
<p>
<input type="text" id="foo" value="" placeholder="Type your text here">
<input type="button" id="bar" value="View changes">
</p>
...
<p>Some text <span id="baz"></span> more text.</p>

<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function(){
    var foo=document.getElementById('foo');
    var bar=document.getElementById('bar');
    var baz=document.getElementById('baz');
    bar.onclick=function()
    {
        baz.textContent=foo.value;
    }
});
</script>

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)