Solved

Change text when typing into field

Posted on 2016-10-28
2
19 Views
Last Modified: 2016-10-28
I need to have text update as the user types into a field.  There's a working example here...

http://jsbin.com/axibuw/1/edit?html,js,output

But it's not working from my page here.

http://testregister.cenational.org/test/sig4.php

Here's the main page code.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<link href="../support/style.css" rel="stylesheet" type="text/css">
<script type="script/javascript">
  $('.chatinput').keyup(function(event) {
    newText = event.target.value;
    $('.printchatbox').text(newText);
  });
</script>

</head>
<body>

  <div class='printchatbox'>CHANGE ME</div>
  <input type='text' name='fname' class='chatinput'>
</body>
</html>

Open in new window


Here's the CSS
.printchatbox 
    {border-width:thick 10px;border-style: solid; 
    background-color:#fff;
    line-height: 2;color:#6E6A6B;font-size: 14pt;text-align:left;float: middle;
    border: 3px solid #969293;width:40%;
	}

Open in new window


There must be something simple  I'm missing. Thanks in advance for any help.

Steve
0
Comment
Question by:stkoontz
2 Comments
 
LVL 19

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
Comment Utility
You have "script/javascript" and it should be "text/javascript":
<!DOCTYPE html>
<html>
	<head>
		<title>
			JQuery Test Host
		</title>
		<script type="text/javascript" src=".\jquery-3.1.1.min.js"></script>
		<!--<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>-->
		<style>
			.printchatbox 
				{
					border-width:thick 10px;border-style: solid; 
					background-color:#fff;
					line-height: 2;color:#6E6A6B;font-size: 14pt;text-align:left;float: middle;
					border: 3px solid #969293;width:40%;
				}
		</style>
		<script type="text/javascript">
			$(document).ready(function() {
				$('.chatinput').keyup(function(event) {
				  newText = event.target.value;
				  $('.printchatbox').text(newText);
				});  
			  });
		</script>		
	</head>
	<body>
		<div class='printchatbox'>CHANGE ME</div>
		<input type='text' name='fname' class='chatinput'>
	</body>
</html>

Open in new window

0
 
LVL 2

Author Closing Comment

by:stkoontz
Comment Utility
That was the little think I missed.  Thanks!

Steve
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now