tried this with css in actuall stylesheet aswell, but i wont work. what have have I done wrong please?

<style>pullquote 
{width: 145px;
background:gold;
color:black;
float: right;
border:1px solid maroon;
font-weight:bold;
line-height:140%;
padding:5px;
margin-top:10px;
margin-left:10px;
}
</style>

<script type="text/javascript">
function addPullquote(){
  var myTextArea = document.getElementById("commentBox");
  myTextArea.value = myTextArea.value + '[dohtml]<p class='pullquote'>
This is your pullquote. 
</p>
[/dohtml]';
}
</script>

<input type="button" onclick="addPullquote();" value="Add a Pullquote"/>


<textarea id="commentBox"></textarea>

Where's the . in front of pullquote in the stylesheet?
Where's the required mime type parameter in the style tag?

<style type="text/css">
.pullquote { 

put your styles here
}
</style>

still dosent work ?

<style>
.pullquote {
{width: 145px;
background:gold;
color:black;
float: right;
border:1px solid maroon;
font-weight:bold;
line-height:140%;
padding:5px;
margin-top:10px;
margin-left:10px;
}
</style>

<script type="text/javascript">
function addPullquote(){
  var myTextArea = document.getElementById("commentBox");
  myTextArea.value = myTextArea.value + '[dohtml]<p class='pullquote'>
This is your pullquote. 
</p>
[/dohtml]';
}
</script>

<input type="button" onclick="addPullquote();" value="Add a Pullquote"/>

Hi there,

this will work for you, the css class is right,

<style>
<!--
.pullquote 
	{
		width: 145px;
		background:gold;
		color:black;
		float: right;
		border:1px solid maroon;
		font-weight:bold;
		line-height:140%;
		padding:5px;
		margin-top:10px;
		margin-left:10px;
	}
-->
</style>

Regards,
Rahul

Thankyou Rahul,
its not writing to the textarea though, is my script wrong?

<script type="text/javascript">
function addPullquote(){
  var myTextArea = document.getElementById("commentBox");
  myTextArea.value = myTextArea.value + '[dohtml]<p class='pullquote'>
This is your pullquote. 
</p>
[/dohtml]';
}
</script>

You have another quote-nesting problem =P:

myTextArea.value = myTextArea.value + '[dohtml]<p class='pullquote'>This is your pullquote. </p>[/dohtml]';

You cannot put the same kind of unescaped quote in a quoted block as is being used to quote the block. To solve:

myTextArea.value = myTextArea.value + "[dohtml]<p class='pullquote'>This is your pullquote. </p>[/dohtml]";

or

myTextArea.value = myTextArea.value + '[dohtml]<p class="pullquote">This is your pullquote. </p>[/dohtml]';

or

myTextArea.value = myTextArea.value + '[dohtml]<p class=\'pullquote\'>This is your pullquote. </p>[/dohtml]';
([B]if you're using this with that forum software that eats backslashes, do this instead:[/B]
myTextArea.value = myTextArea.value + '[dohtml]<p class=\\'pullquote\\'>This is your pullquote. </p>[/dohtml]';
)

or (last one)

myTextArea.value = myTextArea.value + "[dohtml]<p class=\"pullquote\">This is your pullquote. </p>[/dohtml]";
([B]this one for that forum software again:[/B]
myTextArea.value = myTextArea.value + "[dohtml]<p class=\\"pullquote\\">This is your pullquote. </p>[/dohtml]";
)

See if that helps ^_-

Hmm, this one refuses to work full stop, I tried all of those. Very curious. It dosent matter though it was just for learning purpouses. Once again Thanks for the input about those nested Quotes Matt, Ill get the hang of it eventually! :)

You still do not have the mime type in the style tag. It is required.

what is mime type? you mean comments tags? <!-- like--!> ?

No.. You should put a type="text/css" attribute in the <style> tag, in order to comply with guidelines and the like.

Most browsers don't give a stuffing about the type of <script> tags and <style> tags. They make a default assumption that <script> is javascript and <style> is CSS. But hey. you should conform to guidelines, that assumption might not always be the case.

You could also specify the type of all script and style on a page using:

Metatags! (or real HTTP headers)
<meta http-equiv="Content-Script-Type" content="text/javascript" >
<meta http-equiv="Content-Style-Type" content="text/css" >

However, that won't help you much here, it won't make a difference to the Javascript, which incedently is correctly typed (even thought text/javasript isn't a valid MIME type atall ^_-)

With regard to your javascript, I'm gonna give it a test run and let you know the results.. will post back in 5 mins,,

Well, it worked ok.

Here's the code I ran:

<html>
<head>
<title>Javascript test...</title>
<script type="text/javascript">
function addPullquote()
{
  var myTextArea = document.getElementById("commentBox");
  myTextArea.value = myTextArea.value + '[dohtml]<p class="pullquote">This is your pullquote.</p>[/dohtml]';
}
</script>
</head>
<body>

<textarea id="commentBox" cols="80" rows="40">

</textarea>

<button onclick="addPullquote();">Add quote</button>

</body>
</html>

Make sure:
- You give the textarea an ID and not just a name (and make sure the id is identical on the textarea and the document.getElementById() statement, the case is important to)
- You put the script in the <head> section
- You remember nested quoting rules !
- You don't make javascript statements span multiple lines.. It might be the way you pasted it there, but if your javascript statement is like:

myTextArea.value = myTextArea.value + '[dohtml]<p class='pullquote'>
This is your pullquote. 
</p>
[/dohtml]';

The fact that the statement spans more than one line when it's not expected to will cause it to fail.

(If you wanted multiple lines in plaintext output [which you might in a textarea], you could use this escape character: '\n' to do that.)

Any luck now?

Ahh I see, I had the script in the body not the head, No wonder! It works now. Thankyou everyone for you help! :D
[insert embarressed smiley here]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.