Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-26-2012, 12:36 AM   PM User | #1
jace_co_uk
New Coder

 
Join Date: Feb 2012
Posts: 22
Thanks: 2
Thanked 0 Times in 0 Posts
jace_co_uk is an unknown quantity at this point
Split TextBox Words into characters

I have a Text Box which i wish to Place Words into it, once i click the Button it should Split the Words into Characters

E.G
I enter Before in Text box it should Should

B
E
F
O
R
E

Code:
<script language="javascript">

function getTag(){
	
var string = document.getElementById("tag");       
var array = string.getElementById("tag");
var finishedArray = [];
for (var i = 0, il = array.length; i < il; i++) {
  var temp = array[i].getElementById(",");
  for (var j, jl = temp.length; i < jl; j++) {
    finishedArray.push(temp[j]);
	destLayer = document.getElementById('splitResponse');
destLayer.innerHTML='';
  }
}

}
</script>


	<h3>Sentence Splitter</h3>

			<input name="tag" type="text" id="tag" size="30"  autocomplete="off"/>
            <button onClick="getTag();" value="Click"/>Click</button>

			  <div id="splitResponse"></div>
			  <div class="section"></div>
			</div>

Last edited by jace_co_uk; 03-26-2012 at 08:11 AM..
jace_co_uk is offline   Reply With Quote
Old 03-26-2012, 02:43 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Despite the similar sounding names, Java is not the same as Javascript.
Moving from Java forum to Javascript forum.
Fou-Lu is offline   Reply With Quote
Old 03-26-2012, 03:04 PM   PM User | #3
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,765
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Lightbulb

I'm not sure what you 'section' <div> area is about, but this should accomplish the initial request.
Code:
<!DOC HTML>
<html>
<head>
<title> Untitled </title>
<script language="javascript">

function getTag(){
 var arr = document.getElementById("tag").value.split('');
 document.getElementById('splitResponse').innerHTML = arr.join('<br>');
}

</script>
</head>
<body>
<h3>Sentence Splitter</h3>
<input name="tag" type="text" id="tag" size="30"  autocomplete="off"/>
<button onClick="getTag();" value="Click"/>Click</button>
 <div id="splitResponse"></div>
 <div class="section"></div>
</body>
</html>
jmrker is offline   Reply With Quote
Users who have thanked jmrker for this post:
jace_co_uk (03-26-2012)
Old 03-26-2012, 06:08 PM   PM User | #4
jace_co_uk
New Coder

 
Join Date: Feb 2012
Posts: 22
Thanks: 2
Thanked 0 Times in 0 Posts
jace_co_uk is an unknown quantity at this point
the
<div id="splitResponse"></div> is meant to show the content of the split Values inside the text box the rest of the divs are part of the site

You Code Works Well Thanks alot

Last edited by jace_co_uk; 03-26-2012 at 06:17 PM..
jace_co_uk is offline   Reply With Quote
Old 03-26-2012, 07:45 PM   PM User | #5
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
???
Maybe i don't understand what exactly you mean.
PHP Code:
//This is the element contains the word
<div id="theword">I am the word</div>
//This element shows teh characters
<div id="ch"></div
<
script type="text/javascript">
window.onload=function(){
   var 
string=document.getElementById('theword').innerHTML;
   var 
characters=string.split('');
   
document.getElementById('ch').innerHTML='';
   for(var 
i=0i<characters.lengthi++){
         
document.getElementById('ch').innerHTML+=characters[i]+'<br>';
   }
}
</script> 
Labrar is offline   Reply With Quote
Old 03-26-2012, 09:25 PM   PM User | #6
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,765
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Thumbs up

Quote:
Originally Posted by jace_co_uk View Post
the
<div id="splitResponse"></div> is meant to show the content of the split Values inside the text box the rest of the divs are part of the site

You Code Works Well Thanks alot
You're most welcome.
Happy to help.
Good Luck!
jmrker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:41 AM.


Advertisement
Log in to turn off these ads.