Jump to content

Please help me with this assignment


Thane94
 Share

Recommended Posts

<!DOCTYPE html>
<html>
<body>

<input type="text" id="clickSend" autofocus /><br>
<p id="contacts"></p>
<br>
Characters remaining: <input disabled  maxlength="3" size="3" value="160" id="counter"><br>
<br>
<textarea onkeyup="textCounter(this,'counter',160);" id="message">
</textarea>
<br>
Sent message: <p id="poruka"></p>
<button type="button" id="button" onclick="message()">Send</button>

<script>
function textCounter(field,field2,maxlimit)
{
 var countfield = document.getElementById(field2);
 if ( field.value.length > maxlimit ) {
  field.value = field.value.substring( 0, maxlimit );
  return false;
 } else {
  countfield.value = maxlimit - field.value.length;
 }
}

/*___________________________________________*/

var i = 1;

document.addEventListener("click", function createContact(){
	if(document.getElementById("clickSend").value !== '')
	{
		var check = document.createElement('input');
		check.setAttribute('type', 'checkBox');
		check.setAttribute('id', 'number' + i);
		check.setAttribute('value', document.getElementById("clickSend").value);
		check.setAttribute('contactNumber', 'numbers');
		
		var labl = document.createElement('label');
		labl.setAttribute('for', 'number' + i);
		
		labl.appendChild(document.createTextNode(document.getElementById("clickSend").value));
		
		contacts.appendChild(check);
		contacts.appendChild(labl);
		
		document.getElementById("clickSend").value='';
		document.getElementById("clickSend").focus();
		i= i + 1;
	}
});

/*______________________________________________*/


function message() {
	var msg=document.getElementById("message").value;
	document.getElementById("poruka").innerHTML=msg;
}

</script>
</body>
</html>

So, checked numbers wont display with the message from text area when send button is clicked. I tried lots of different solutions but neither of those helped. So please if you can help me with this. Thank you.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...