Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting dynamic Html-Input 1

Status
Not open for further replies.

srudin

Programmer
Jan 1, 2002
32
CH
Hi
i got a textfield set to "input" and marked as html; how can i get the REAL text out (without the html-tags)?
the selection-object counts correctly, but seems to deliver only the indexes, not the content...
thanks for suggestions
 
Wath are you looking for exactly?
Displaying a text altered with html tags?
Very few tags from html 1.0 are supported in Flash!
Which ones are you using?

Regards,
wink4.gif
ldnewbie
 
just the basics: <P> and <FONT> with face, size and color.

sorry, maybe my description is a bit too abstract. let me make an example:
1. i put in a textbox where face=arial, style=input, html=true
2. while running, i set the textbox to: &quot;<FONT face=Times>Test</FONT>&quot;
3. now the user enters something, let's say changes test to testblabla
4. i would like to get the value of the textbox; but the value is: &quot;<FONT face=Times>test</FONT><FONT face=Arial>blabla</FONT>&quot; - but i only need testblabla! in other words: the string does not only contain the value but also the html-format, which i would like to separate. guess i'm looking for something like a getSelection-property or a getValueOfHtmlString-function...;-)
4a. actually the same problem occurs with Test (without the user entering something); for example when you want to change the font values while showing the textbox, or setting it dynamicaly.
4b. assuming the cursor between V: testVblaVbla - the selection-object returns beginindex=4 and endindex=7; but whatof? how can i get bla? textbox.substring(4, 7) returns something like &quot;T fa&quot; (from FONT face)...

i mean i could do it without html, then it would be easy; but looks bad when everything else is adjusting dynamicaly.

i guess this problem is either veeery easy or veery tricky; hope it's the first...

thank you in advance
 
Hey!
Asked on the Javascript Forum, and this chap came up with this... Seems to be working fine!

stop ();
// Set input beginning text...
test = &quot;<b>INPUT</b><i>BlaBlaBla</i>&quot;;
// Dynamic textfield (test2) without html checked
test2 = strip(test);
//
function strip (str) {
var left = &quot;<&quot;;
var right = &quot;>&quot;;
var first = str.indexOf(left);
var last = str.indexOf(right);
while ((first>=0) && (last>first)) {
var part1 = str.substring(0, first);
var part2 = str.substring(last+1, str.length);
str = part1+part2;
first = str.indexOf(left);
last = str.indexOf(right);
}
return str;
}
//
trace (test2);

Gave him my vote (which you can't give me - not being registered), and best wishes for the New Year!

Same to you, if you ever come back!

Regards,
wink4.gif
ldnewbie
 
hey
thanks for holding on!
i'm glad to see that your suggestion is exactly the same as what i finally came up with. the tricky thing about it is that you have to adjust the text each time a key is pressed since flash wrapps the new input in its own tags... :-# - but this is tricky since it may cause huge delays! anyway, after much testing i finally found a way to make it work; this way i can even block the cursor from jumping on the second line (because of the <P>)!
if someone's interested in that, i may post an example.

thank you again Idnewbye and a pleasant 2002 to all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top