| View previous topic :: View next topic |
| Author |
Message |
optomeb
Joined: 19 May 2006 Posts: 113
|
| Hey.. I am trying to use createTextRange on a textarea object but it keeps returning undefined, the textarea is not null though.. anyone know what I'm forgetting? |
| |
|
|
|
|
montanarry
Joined: 13 May 2006 Posts: 175
|
| did you define it? |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| Defined which of them? the textrange? |
| |
|
|
montanarry
Joined: 13 May 2006 Posts: 175
|
| Your textrange var |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
Ah.. well yea.. I got a var rng = tbx.createTextRange; doesnt that qualify as defining it?
Hmm.. or do I have to define it on the textarea somehow first? |
| |
|
|
montanarry
Joined: 13 May 2006 Posts: 175
|
You did use name on the textarea right
Mandatory
Just sayinn |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
Well.. I got it like this.. var tbx = document.getElementById("textareaId").. then I used tbx.createTextRange
Er.. or what do you mean? =)
I'm quite a rookie at javascript.. |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
| Have you set the id and name for form (textarea) ? |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| Hmm not the name |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
I never do that in textarea, but let me share similiar case:
<form name="add_tour" action="tour.php" method="post" onSubmit=showSelected()> <input id="add_tour_category" name="add_tour_category" type="hidden"> <select id="Enabled_Category" name="Enabled_Category" size="5" multiple style="width: 100px;"><option blah blah></select><input type="submit" value="Submit"></form>
In javascript:
Var optionList_Category = document.getElementById("Enabled_Category").options; var data_Category = ''; var len_Category = optionList_Category.length; etc
That will get all value in Enabled_Category :)
About this: <input id="add_tour_category" name="add_tour_category" type="hidden"> i will send the processed value to tour.php
So there will be something like this: document.getElementById('add_tour_category').value = data_Category;
Maybe this can give you an idea of your problem |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
Hmm.. well it's not exactly the same I think.. I'm just trying to put some text at the end of the text in a textarea when I click a button
So, im trying to get the position of the cursor in that textarea..
But it seems to me I should be able to use just the length of the text in the textarea or something.. and put the stuff after there.. |
| |
|
|
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
Oh sorry, i never do that before..
I think my dumb idea:
Get all the text in the textarea, make sure it works.. you can check it with alert() in javascript |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| Well it started as: Why my createTextRange on my textarea always is undefined |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
| Then add your new text in saved text (from textarea) that you already store in javascript variable |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| Yea, but how do I get the text from the textarea ? |
| |
|
|
Jackil
Joined: 24 May 2006 Posts: 97
|
| Formref.elements[textAreaName].value |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
| StrFull = strTextarea + strNewTextarea |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| Ah |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
| I think something like that |
| |
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| Lemme give it a shot.. |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
Then you can re-add the strFull to the textarea
like i said you before, i never tried it before.. ok let me try it, just a secs.. |
| |
|
|
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| It works now.. thanks |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
how is it?
<textarea name="textareaId" id="textareaId"></textarea> ?
Then you use document.getElementById("textareaId") ? |
| |
|
|
|