An append button: Text from Textarea to <p> issues

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 1756 Views - Last Post: 10 February 2013 - 08:47 PM

#16 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 04 February 2013 - 10:09 PM

Ok Thanks. i had a spelling error. and now it is fixed.... Thank you for your help alot.
Was This Post Helpful? 0
  • +
  • -

#17 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3515
  • View blog
  • Posts: 10,143
  • Joined: 08-June 10

Re: An append button: Text from Textarea to <p> issues

Posted 04 February 2013 - 10:14 PM

View PostEadmanday, on 05 February 2013 - 05:57 AM, said:

so if i use document.write it takes away all my CSS and just throws the words onto white background.

yepp, document.write() used after the page finished loading causes everything to be erased.

... a good reason never to learn it in the first place.

View PostEadmanday, on 05 February 2013 - 05:57 AM, said:

I was thinking that the Innter.HTML would append or replace the info in the p-tags?

it does. but it only does so when you do an assignment. in contrast, a comparison does not change anything.
Was This Post Helpful? 0
  • +
  • -

#18 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 04 February 2013 - 10:21 PM

Ya. i now need to find out how to make the textarea clear after each click of the button.
Was This Post Helpful? 0
  • +
  • -

#19 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3515
  • View blog
  • Posts: 10,143
  • Joined: 08-June 10

Re: An append button: Text from Textarea to <p> issues

Posted 04 February 2013 - 10:21 PM

set its .value to "".
Was This Post Helpful? 1
  • +
  • -

#20 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 04 February 2013 - 10:27 PM

Mmmm.. in JS? not working for me but i will still play around with it.
Was This Post Helpful? 0
  • +
  • -

#21 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3515
  • View blog
  • Posts: 10,143
  • Joined: 08-June 10

Re: An append button: Text from Textarea to <p> issues

Posted 05 February 2013 - 04:15 AM

then youíre doing something wrong. a <textarea> has, like every other form control, a value property.
Was This Post Helpful? 0
  • +
  • -

#22 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 05 February 2013 - 01:21 PM

Here is the working code. Thanks for the help guys.



window.onload = function()  { 
document.getElementById("Paste").onclick = function() {


//var y = document.getElementById('paste').onclick
var paragraph = document.getElementById('box').value;
var x = document.getElementById("write");
var getInfo = document.getElementById('ParaWrite');
var ptag = " ";
	 
	 if (x.checked === true)
	{
 	document.getElementById("box").value = "";
	getInfo.innerHTML = "<p>"+paragraph+"</p>";
	
	}
		
 else{
 	document.getElementById('box').value = "";
	getInfo.innerHTML += paragraph+"<p></P>";
 
 

	}


  }    
}



<!doctype html>
<html>
<head>
  <meta charset="utf-8">

  <title>Paragraph</title>
  
 
  <link rel="stylesheet" href="../css/normalize.css">
  <link rel="stylesheet" href="Textbox.css">
  
  
</head>

<body>
<h1>Please enter some Text</h1>
<form name="form1" id="form1">

<input type='checkbox' name='write' id='write' value='Check' />

<label for='write'>Replace all paragraphs with this one.</label><br/>

<textarea type="text" id="box" value=""/></textarea>

<input  type='button' value="Paste typed text" id="Paste"/>

</form>
<div id="ParaWrite">

</div>


<script type="text/javascript" src="TextPara.js"></script>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#23 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3515
  • View blog
  • Posts: 10,143
  • Joined: 08-June 10

Re: An append button: Text from Textarea to <p> issues

Posted 05 February 2013 - 04:35 PM

out of curiousity, why does line #20 append an empty paragraph?
Was This Post Helpful? 0
  • +
  • -

#24 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 06 February 2013 - 06:23 PM

View PostDormilich, on 05 February 2013 - 04:35 PM, said:

out of curiousity, why does line #20 append an empty paragraph?


The teacher wanted the information to be pasted in the paragraph tag. so if you enter "Hello" and click the botton. then it would put hello in the p-tag.... if you typed world it would then put world in a new P-tag while keeping "world".
Was This Post Helpful? 0
  • +
  • -

#25 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3515
  • View blog
  • Posts: 10,143
  • Joined: 08-June 10

Re: An append button: Text from Textarea to <p> issues

Posted 06 February 2013 - 10:04 PM

so itís a typo? (since the text is not in the paragraph)
Was This Post Helpful? 0
  • +
  • -

#26 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 07 February 2013 - 01:48 PM

View PostDormilich, on 06 February 2013 - 10:04 PM, said:

so itís a typo? (since the text is not in the paragraph)


Ya, thinking about it now it would be better in the tag. I had it out of the tag so it would start a new paragraph. but re looking at the code i don't think i need that.
Was This Post Helpful? 0
  • +
  • -

#27 JMRKER  Icon User is offline

  • D.I.C Addict

Reputation: 128
  • View blog
  • Posts: 826
  • Joined: 25-October 08

Re: An append button: Text from Textarea to <p> issues

Posted 07 February 2013 - 07:11 PM

View PostEadmanday, on 04 February 2013 - 10:57 PM, said:

Ok. so this is slowly starting to make scene to me, And i thank you for your help.

so if i use document.write it takes away all my CSS and just throws the words onto white background. I was thinking that the Innter.HTML would append or replace the info in the p-tags?


There is no 'Innter.HTML'.
I believe you want '.innerHTML'
Was This Post Helpful? 0
  • +
  • -

#28 Eadmanday  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 49
  • Joined: 23-October 12

Re: An append button: Text from Textarea to <p> issues

Posted 10 February 2013 - 08:47 PM

ya. That is one of the first things i am starting to check on my debugging process.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2