Solved

Change text when typing into field

Posted on 2016-10-28
2
46 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 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 41864454
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
ID: 41864483
That was the little think I missed.  Thanks!

Steve
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

830 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