redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

returning undefined



 
Post new topic   Reply to topic    Web Design Forums -> JavaScript forum
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?
  Reply with quote


montanarry



Joined: 13 May 2006
Posts: 175
did you define it?
  Reply with quote
optomeb



Joined: 19 May 2006
Posts: 113
Defined which of them? the textrange?
  Reply with quote
montanarry



Joined: 13 May 2006
Posts: 175
Your textrange var
  Reply with quote
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?
  Reply with quote
montanarry



Joined: 13 May 2006
Posts: 175
You did use name on the textarea right
Mandatory
Just sayinn
  Reply with quote
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..
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
Have you set the id and name for form (textarea) ?
  Reply with quote
optomeb



Joined: 19 May 2006
Posts: 113
Hmm not the name
  Reply with quote
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
  Reply with quote
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..
  Reply with quote


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
  Reply with quote
optomeb



Joined: 19 May 2006
Posts: 113
Well it started as: Why my createTextRange on my textarea always is undefined
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
Then add your new text in saved text (from textarea) that you already store in javascript variable
  Reply with quote
optomeb



Joined: 19 May 2006
Posts: 113
Yea, but how do I get the text from the textarea ?
  Reply with quote
Jackil



Joined: 24 May 2006
Posts: 97
Formref.elements[textAreaName].value
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
StrFull = strTextarea + strNewTextarea
  Reply with quote
optomeb



Joined: 19 May 2006
Posts: 113
Ah
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
I think something like that
  Reply with quote
optomeb



Joined: 19 May 2006
Posts: 113
Lemme give it a shot..
  Reply with quote
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..
  Reply with quote


optomeb



Joined: 19 May 2006
Posts: 113
It works now.. thanks
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
how is it?
<textarea name="textareaId" id="textareaId"></textarea> ?
Then you use document.getElementById("textareaId") ?
  Reply with quote
Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> JavaScript forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group