Click to See Complete Forum and Search --> : how can i chekc if my string contains (') or (")


pelegk1
07-23-2003, 01:55 AM
i tried to do this but it isnt working :
text=document.all["streetName"+index].innerText;
if (text.indexOf(""",0)) {
index=text.indexOf(""",0);
alert(index);
}
in the index i get -1 !!! -:{
what to do to check which 1 is in my string>?
thanks in advance
PEleg

skriptor
07-23-2003, 02:22 AM
HI,
try this:

text=document.all["streetName"+index].innerText;
if (text.indexOf("\"",0)) {
index=text.indexOf("\"",0);
alert(index);
}

Good luck, skriptor

pelegk1
07-23-2003, 02:26 AM
but i have another problem when i send to another page a variable that contains (') or (")
and want to put it in a value i get an error on th page! :(
what to do?
thanks in advance
Peleg

skriptor
07-23-2003, 02:42 AM
Hi,
without knowing the details, perhaps this could solve your problem:

a = 'hello"hello'
b = escape( a )
alert ( b + " -> " + unescape( b ) );

do the escape on first page and the unescape on second.

Good luck, skriptor

pelegk1
07-23-2003, 02:58 AM
if i have in the string (') or (") (1 of this 2)
how can i know if to put into the variable :

a = 'hello"hello'
or
a = "hello'hello"


b = escape( a )
will it work ok for both of the "a" strings?
thanks in advance
Peleg

skriptor
07-23-2003, 03:54 AM
Hi,
escape() always works.
Refering to your first question variable a will set by, I think :
a = document.all["streetName"+index].innerText;

So you can continue with escape( a ).

Good luck, skriptor.

pelegk1
07-23-2003, 05:34 AM
ESCAPE(A)
WHEN I AM ON THE SECOND PAGE AND DO
REQUEST("A")
I GET THE ORIGINAL STRING AND NOT THE 1 IN THE ESCAPE FORAMT!!!

skriptor
07-23-2003, 05:48 AM
Hi,
I don't understand your problem. Gimme some coding to look at.
Skriptor.

pelegk1
07-23-2003, 06:13 AM
i got
a = 'hello"hello' ;
alert ( escape( a )) ; -> here i got : hello%22hello
but when i read this on the next page withogut even using the
unescape function i see hello"hello and not hello%22hello
!!!!
and that the problem!!!!!
why on the next page i see hello"hello and not hello%22hello
as i sent?

skriptor
07-23-2003, 06:50 AM
Hi,
if you got a unescaped value, be happy, because this is what you want, isn't it?
Where the string is unescaped I can not say, because I don't know the details.
If you want to unescape a string on your own, just do the escape() twice ;)

Bye, skriptor

pelegk1
07-23-2003, 08:03 AM
i see u didnt understand!!!
i wanted to get the escape() value as it is in the posted data
but for unknown reason i get the unescape() value!

SlankenOgen
07-23-2003, 08:09 AM
a = escape(a);

alert(a);

pelegk1
07-24-2003, 12:32 AM
what i talk about is when u use GET method and call another page
and in the other page it dosent show it as escape()
but show's it as i did unesacpe() (which i didnt do!!!)

Exuro
07-24-2003, 12:47 AM
Did you ever actually change the value of your Input element? I never say anything in the code like "element = escape(txt)". But I don't think that'd have done any good anyway. I'm pretty sure that your GET method automatically unescapes everything it gets anyway.

pelegk1
07-24-2003, 02:57 AM
then we are back to the beggining........................................................................................... .................................................................................................... .................................................................................................... .................................................................................................... .................................................................................................... .................................................................................................... .................................................................................................... .................................................................................................... .................................................................................................... ...............................................