PDA

View Full Version : Urgent Reply Needed


sarwat
09-09-2002, 11:57 AM
Can I set up a textbox where the user can enter and edit the text (Bold, Underline, Font, etc.) without having to enter in HTML code?

KINDLY GIVE TH EXACT CODE BECAUSE I CAN'T FIND IT ANYWHERE

joh6nn
09-09-2002, 03:11 PM
can you give a more exact description of what you want? maybe with an example?

sarwat
09-09-2002, 04:21 PM
thanks for the reply....What i want is to give user a toolbar in my asp or html page through which user can apply different options on his text like bold,italic,underline,font size,font style etc.

Now i can't understand how to give it....I have searched it everywhere but no result .....

Its the same option we get while we are writing our mail at yahoo....like by selecting a particular text i can increase my font size by just selecting an option from the font size list.....

can u help me to solve it....???

hairynugs6382
09-09-2002, 04:27 PM
Php colud solve your problem for you. Do you mean, bold, italic, underlined as you can use on this forum in your posts because that i believe is PHP i think that this hole site is in php someone corrcect me if i am wrong.

ConfusedOfLife
09-09-2002, 05:06 PM
Unfortunately it's no time to answser you in the way that I like, I wrote an ugly thing, but it works, see if its what you want:


<script>
function change(what)
{
switch ( what )
{
case "oblique" :
document.getElementById("test").style.fontWeight = "normal";
document.getElementById("test").style.fontStyle = what;
break;
case "bold" :
document.getElementById("test").style.fontStyle = "normal";
document.getElementById("test").style.fontWeight = what;
break;
}
}
</script>
</head>

<body>
<input id="test" type="Text" validationmsg=""><br>
<a href="javascript:change('oblique');">Italic</a><br>
<a href="javascript:change('bold');">Bold</a>

</body>

sarwat
09-09-2002, 08:29 PM
yeah i want exactly the same thing butl my problem hasn't still been solved :(

I have tried your code but it doesn't work...the href u r giving doesn't works...

yeah i need the same sort of thing but the code isn't working....

please help me in again....i guess there is some problem in the code ....:confused:

sarwat
09-10-2002, 03:50 PM
I haven't still not got any solution of my problem....please help me .....

ConfusedOfLife
09-10-2002, 11:33 PM
Sorry, I was typing too fast! You should have noticed ( I mean actually I should have noticed! ) that little space between java and script in both hrefs, delete them, and your code is gonna work!
Something else, are you trying to have a WYSIWYG ( What You See Is What You Get ) editor? You asked about the toolbar that's in here when you type your messages, it's not one of them, coz for example you have to put [ i ] ( I hope it shows it! ), and a closing one ( like HTML ) and then, you'll see the results later, when you click the submit reply button. Making this is easy, you just have to write a program to query the value of a text area for your tags ( whatever you define ), but making a WYSIWYG with JS, is impossible, eventhough I hate this word, but I hope someone corrects me if I'm wrong.

hairynugs6382
09-11-2002, 12:58 AM
I pretty sure that this site is run by php!

ConfusedOfLife
09-11-2002, 11:24 PM
Well, yeah, of course! I can see P, H and P written in my browser's address bar whenever I enter this site, but making this thing is pretty easier with javascript ( I actually do thing that's made by JS! ) and it's also what " Simple is best" tells us. For making an editor like the thing that I'm using now for entering my text, you can use pure javascript, and I think that they just use PHP to save the contents into a file that they can catch later ( I'm not sure about this part! ), but you can have a simple textarea, asking ppl to type whatever they like, then can even use tags for making their text bold, italic or whatever ( Using html tags for doing this! ), changing the color, inserting a picture, making a hyper link, and then you simply get the value of your textarea and write it into a new document, then it's gonna be a page, exactly like the thing that happens in here ( maybe it doesn't happen exactly in this way in here! ), but it's well, very simple!

hairynugs6382
09-12-2002, 12:52 AM
It means exactly what it says SIMPLE IS BEST! Its just something that I try to abide by when designing a web page! I can't stand sites that are cluttered up witth useless shyt! What does confusedoflife mean?

Leinad
09-12-2002, 07:00 AM
Is it something like the textarea in YahooMail or Hotmail when you try to compose a message?

ConfusedOfLife
09-12-2002, 11:23 PM
Well, it's exactly what I'm trying to say! Nobdy likes such sites, at least if they can understand what a site means. I just thought that by repeating that this site is made by PHP, you're trying to say that it's better that we write this thing with PHP ( I don't know if it's possible or not, I don't know PHP! ), and I wanted to mention that it's no need to do that with PHP when you can do it much easier with javascript!
And for dear Leinad, I don't work with yahoo that much, but if you're speaking about a textarea in this site that you write your posts, then yes.

sarwat
09-18-2002, 09:20 AM
Thanks to all of u people helping me out :
Although i have read all your replies but still my problem is there...
i have asked many people about it and all of them are saying that it won't be so easy to desiggn a thing like yahoo mail or hotmail wherein we get a toolbar to design our message acoording to our wish....

But still if anyone of u have some idea about it then do write in again...

but once gain thanx to all of u for your co-operatipon

ConfusedOfLife
09-18-2002, 11:15 AM
It's hard and it's not hard! In yahoo or hotmail, or just let's talk about this forum, ok? Where you're typing is a textarea, ok? Well, let's say that this text area is called "oText" and you have a control panel above your text area, for example with some sets of smileys, ok? so, whenever someone clicks on a smiley, a kind of code is added to the END of the textarea, I mean to the last character of our textarea, you can try it yourself, type something in the textarea, and then move your cursor to some upper lines and click on the "confused" smiley! ( my smiley ), you'll see that it's NOT gonna be added to the place that your cursor is standing, but it's gonna be added to the end of your text area, and it has a special code, like for example ":con" ( I don't write the exact code, coz it's gonna replace it with the smiley itself later), so, writing this thing is very easy, you just put an onclick event for each smiley picture saying that it should add a relevant code to the end of our text area, I mean "oText", the onclick would look like this:

onclick="document.oText.value += ':con'"

ok? everything's clear, but in the end, when the user presses the submit button, then you have to parse the value of your textbox, and whereever you see a code that shows a smiley, you replace with :

<img src="your_relevant_image_based_on_the_code.jpg">

ok? in the end, after doing all the replacements, you're just gonna simply write your new value into the document by document.write(newValue) into a document, the current document, or a new window document. Just writing the program that parses the whole textarea's value and replaces everything that you like needs some hours, but it's not hard at all. Try to write a text editor in C or other basic languages, and you find out what's hard and what's not! ( it's not hard either )

Let's say you wana have for example a [ size ] tag that whenever the user types that and specifies a size, then the text within that tag be in the specified size, if you use the format of HTML tags, then it's already done! If you define a button in your control panel called small Font, and by pressing the button it adds <font size=5></font> to your textarea's value, then if you write your value into the document, it'll work by itself, coz you know that if you write HTML tags into the document, they work. You can even prompt the user to enter what he wants, and then you write document.write("<font size=5>" + userEntry + "</font>"); and it'll work just fine. That userEntry is gonna be taken after the user presses your button and by writing

usdrEntry = window.prompt("Enter your text in here","");

So, if you use HTML tags and you do not have any smileys, then you already can make your control panel, but if you wana have smileys and also your tags are gonna be different with the HTML tags, then you need a function to query all the textarea's value and replaces the tags with the HTML tags and smileys' codes with <img> tags with the relevant src. It's just one way, there should be some other ways, and maybe the control program is totally different, but what I said is gonna work.

ASAAKI
09-18-2002, 05:27 PM
Originally posted by ConfusedOfLife
... so, whenever someone clicks on a smiley, a kind of code is added to the END of the textarea, I mean to the last character of our textarea, you can try it yourself, type something in the textarea, and then move your cursor to some upper lines and click on the "confused" smiley! ( my smiley ), you'll see that it's NOT gonna be added to the place that your cursor is standing, but it's gonna be added to the end of your text area ...
That's all very well. What I'd <extreme emphasis>love</extreme emphasis> to know though, is how to make that smiley appear WHERE THAT CURSOR IS, the way it happens in Hotmail or Yahoo, or even MS Word, for that matter.

beetle
09-18-2002, 06:09 PM
You can do that here (http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130)

However, for all the HTML functions, why not just use htmlArea (http://www.interactivetools.com/products/htmlarea/)?

I mean, no point in re-inventing the wheel, right? :D (unless you just wanna practice/learn)

ASAAKI
09-19-2002, 12:28 AM
oh thank you beetle!! i've been wanting this for EONS...

whammy
09-19-2002, 02:18 AM
Hmm... that is pretty cool, I think I'll use that in a couple of internal apps to save time. :)

ConfusedOfLife
09-22-2002, 06:37 PM
Sorry, I was on a trip and I couldn't answer to my emails, well, for that question ASSAKI, I just have something in my mind, that might be harder than the link that beetle gave ( I didn't check it out yet ), but what I suggest is to use a stack and getting all the codes entered in your textarea by onkeypressed and then you can code everything, I mean if it's a normal character then it's gonna be pushed into the stack normally, but if someone clicks on a smiley, then you can push a code into the stack and blah blah ( you have to do it for all the tags, like [ i ] or [ b ] too ), then for writing that on the monitor in the way that you like, you have to convert the data of your stack to the postfix form ( if it's 5 + 2, then it's gonna be 52+ for example, if you don't know what postfix and infix values are, then you have to go for it! unfortunately it's no time that I explain them in here, but they're pretty easy ), because you need to know the precedence of the tags and smileys and characters ( typically all your entry ) to show them correctly in the output. Anyway, it looks scary to me too and I'm sure that it could be written, but it should be an easier way to use the embedded JS functions that's gonna make the whole work much easier.

Conclusion : Don't even think of writing that in this way! It's not worth it I suppose!

ASAAKI
09-23-2002, 12:01 PM
hmmm...maybe it's scary, but it's a possibility...didn't think of it... i suppose i cud use the onkeypress idea for other form stuff...