Ok Thanks. i had a spelling error. and now it is fixed.... Thank you for your help alot.
27 Replies - 911 Views - Last Post: 10 February 2013 - 08:47 PM
#16
Re: An append button: Text from Textarea to <p> issues
Posted 04 February 2013 - 10:09 PM
#17
Re: An append button: Text from Textarea to <p> issues
Posted 04 February 2013 - 10:14 PM
Eadmanday, 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.
Eadmanday, 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.
#18
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.
#19
Re: An append button: Text from Textarea to <p> issues
Posted 04 February 2013 - 10:21 PM
set its .value to "".
#20
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.
#21
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.
#22
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>
#23
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?
#24
Re: An append button: Text from Textarea to <p> issues
Posted 06 February 2013 - 06:23 PM
Dormilich, 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".
#25
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)
#26
Re: An append button: Text from Textarea to <p> issues
Posted 07 February 2013 - 01:48 PM
#27
Re: An append button: Text from Textarea to <p> issues
Posted 07 February 2013 - 07:11 PM
Eadmanday, 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?
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'
#28
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.
|
|

New Topic/Question
Reply



MultiQuote




|