weird textbox
Moderator: General Moderators
weird textbox
Hello. I'm newbie here and in php programming, and I have some question for you. Can anyone tell me is it possible to create a php-designed textbox in which cursor isn't at the begining of textbox? On every textbox, when I click on it, cursor is at the begining of textbox, and I can't type anywhere else but at the begining, unless I type "space". I want textbox which is flexible with typing place, wherever I click to type - in the center, up, down, left or right. Is it possible to create and what would be code for it?
Re: weird textbox
You could add spaces between your <textarea></textarea> tags. You would need to count the correct number of spaces (which I didn't do here). Also, when text is entered in the textbox, it will just push the spaces after it forward, and there would still be the spaces before it, so you'd want to trim() the input before you store it.
I tried this and it seemed to work in Safari, but no idea how other browsers would handle it. Might need to use instead of spaces?
Code: Select all
<form>
<textarea cols="20" rows=" 12">
</textarea>
</form>
Re: weird textbox
Why would you want to do that anyway? It'll only confuse users
Re: weird textbox
Thank you, I tried, it's working, but can anyone think of something better, because it's turning my textbox bigger and bigger. I want when I type one letter- one empty space to be deleted because of my letter, if you know what I mean. I don't know to trim() it.
Well, I imagine it like one big sheet of paper, which would use for notes. In real life, I can write wherever I want, not just at the begining of the first line. I just want to make it like a real paper. What do you think?:)
Well, I imagine it like one big sheet of paper, which would use for notes. In real life, I can write wherever I want, not just at the begining of the first line. I just want to make it like a real paper. What do you think?:)
Re: weird textbox
Press the "Insert" or "INS" key on your keyboard. (Edit: This does not work.) This will toggle your typing mode from "insert" to "overwrite". Use the <textarea>-filled-with-spaces idea along with overwrite mode.
You can do a similar thing with Javascript and remove a character from the line as you type.
Edit: This post was recovered from search engine cache.
You can do a similar thing with Javascript and remove a character from the line as you type.
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Tue Jun 15, 2010 10:57 pm, edited 1 time in total.
Re: weird textbox
Hi kuzco,
If you're wanting to create the ability to put your text in different places, I think you need to be putting it in a <div>. Short of writing your own javascript, you can check out a WYSIWYG editor like TinyMCE. http://tinymce.moxiecode.com/examples/full.php
See how on the fourth row there's a little white box, it's the firs button? Click on it, and it creates a "layer" (really, just a <div>). You can then drag this around wherever you feel like. Does that help a bit?
If you're wanting to create the ability to put your text in different places, I think you need to be putting it in a <div>. Short of writing your own javascript, you can check out a WYSIWYG editor like TinyMCE. http://tinymce.moxiecode.com/examples/full.php
See how on the fourth row there's a little white box, it's the firs button? Click on it, and it creates a "layer" (really, just a <div>). You can then drag this around wherever you feel like. Does that help a bit?
Re: weird textbox
Well, as for Insert button, it doesn't work. I don't know is it working with your computer, but if it's working, please copy that code for me. I can type with Insert button, but when I view it as html page, it's the same, textbox goes bigger and bigger, letters don't eat spaces.
As for TinyMCE, it's really great thing, it can help me solve some problems, but not this, because I think users will get bored while they click to add new layer, I just want to have it on start. What do you think? I just want to make them use my textbox like a piece of paper, nothing else.
As for TinyMCE, it's really great thing, it can help me solve some problems, but not this, because I think users will get bored while they click to add new layer, I just want to have it on start. What do you think? I just want to make them use my textbox like a piece of paper, nothing else.
Re: weird textbox
I think you're going about this all wrong.
If you want to create an application that allows you to type anywhere in a textbox and that's mimiced on the screen then this is definitely not the way to do it, and here's for why:
Most browsers allow you to change text size. Press ctrl and scroll your mouse. If a user does that then your whole application dies. What about users resolutions? Sure you can use set widths but doesn't that defeat the whole object?
I never normally recommend Flash but maybe you should take a look at it. It's not too difficult to create an application that allows you to write or draw on screen and the server saves the data. Might be a better option for you. Probably easier than fannying about with textbox behaviours.
If you want to create an application that allows you to type anywhere in a textbox and that's mimiced on the screen then this is definitely not the way to do it, and here's for why:
Most browsers allow you to change text size. Press ctrl and scroll your mouse. If a user does that then your whole application dies. What about users resolutions? Sure you can use set widths but doesn't that defeat the whole object?
I never normally recommend Flash but maybe you should take a look at it. It's not too difficult to create an application that allows you to write or draw on screen and the server saves the data. Might be a better option for you. Probably easier than fannying about with textbox behaviours.
Re: weird textbox
Here is something that might be interesting or useful to you. It allows you to type directly onto the page without using form elements. The keycodes.js file is in the attachment.
Edit: This post was recovered from search engine cache.
Code: Select all
<html>
<head>
<title>Page Typing</title>
<script type="text/javascript" src="keycodes.js"></script>
<script type="text/javascript">
// <![CDATA[
document.onkeydown = start;
function start (e)
{
var log = document.getElementById('message');
var msg = log.innerHTML;
var ev = navigator.appName == 'Netscape' ? e : event;
var k = ev.keyCode;
var key = ev.shiftKey ? shiftKeyCodes[k] : keyCodes[k];
if (key.toLowerCase() == 'backspace') {
msg = msg.substr(0, (msg.length - 1));
}
if (key.length > 1 || key == '' || key == '') {
key = '';
}
log.innerHTML = msg + key;
return false;
}
function isAlphaKey (k)
{
if (k > 64 && k < 91) {
return true;
}
return false;
}
function isNumberKey (k)
{
if (k > 47 && k < 58) {
return true;
}
return false;
}
// ]]>
</script>
</head>
<body>
<h1 id="message">Start Typing: </h1>
</body>
</html>
- Attachments
-
- keycodes.js.zip
- (1.56 KiB) Downloaded 12 times
Last edited by McInfo on Tue Jun 15, 2010 11:02 pm, edited 2 times in total.
Re: weird textbox
I think MikeMike is right, if you want something like that, Flash may be a good option. Ajax would be good too, but is much more difficult to make it work right. That said, TinyMCE is quite configurable. If you want it to start out with some content, you can do that. You can change its size, and you can remove any buttons you don't want. If you want to make a full-page area where they can make little boxes, and move them around, typing whatever they want in them, then TinyMCE can do that for you with just a little configuring. Beyond that, I'd say look at Flash, or find an Ajax developer.
Re: weird textbox
Ok, I think that it can be done in flash, but I wanted to know can anyone help me to do it in php... Thank you, at least you helped me with other textbox things.
Btw, that code for typing all over the page is cool, but it's not what I wanted... Thanks anyway!
Btw, that code for typing all over the page is cool, but it's not what I wanted... Thanks anyway!
Re: weird textbox
OK, so let's back up a bit.
Let's say we have a blank page. Let's say a user arrives at said page. What do you want them to see, and what do you want them to be able to do?
Let's say we have a blank page. Let's say a user arrives at said page. What do you want them to see, and what do you want them to be able to do?
Re: weird textbox
Like I said, a simple piece of paper. I'll put it anywhere.
Re: weird textbox
"Simple Piece of Paper" is hardly simple in terms of a web page!
Do you want it to take up the whole screen? Just part of it? Do you want it to be small or large? Change Size? How will the resulting changes be used? Will you need to save it to a database, or is it just temporary? Do you want the text to be searchable?
Do you want it to take up the whole screen? Just part of it? Do you want it to be small or large? Change Size? How will the resulting changes be used? Will you need to save it to a database, or is it just temporary? Do you want the text to be searchable?
Re: weird textbox
a1, a2, a3, a4 or a5? 