A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: using "" within a input text box

  1. #1
    Member
    Join Date
    Apr 2004
    Posts
    49

    using "" within a input text box

    i have an input text box called search. The problem is i need the user to enter...

    "horror films" AND dvds

    and perform an action if they do. So ideally i would write...

    if (_root.search==""horror films" AND dvds") but this doesnt work as the "" are reserved for actually quoting the value, so it messes things up.

    is there a way around this?

    thanks

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    If you are using MX or MX2004, you can give you input box a unique instance name such as search_txt. Then in your if statement you could have if (_root.search_txt.text.toLowerCase()=="horror films and dvds")

    One problem you may run into and that is letting the user type their own criteria. If your search criteria is based on specific data, a combobox may be better.

  3. #3
    Member
    Join Date
    Apr 2004
    Posts
    49
    thanks for the reply.

    not sure if i explained myself correctly.

    i have given the input box an isnstance name of search.

    its working fine if i use the code...

    if (_root.search=="horror films AND dvds")

    and the user was to enter: horror films AND dvds

    but i need it to work if the user was to enter : "horror films" AND dvds

    so the extra "'s are actually part of the input the user would enter. i just dont know how to alter the if statement.

  4. #4
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    There are two ways to work around this:

    1. Use single quotes for delimiting pattern string (and double quotes inside it):

    if (_root.search=='"horror films" AND dvds')

    2. Use a backslash in front of the interior quotes (this is called 'escaping' the quotes):

    if (_root.search=="\"horror films\" AND dvds")

    - Jim

  5. #5
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    if "searsh" is instance name then
    if(_root.search.text=="\""+"horrors films"+"\""+" AND dvd"){...

    if "search" is var then
    if(_root.search=="\""+"horrors films"+"\""+" AND dvd"){....

    Ups, it seams I am late.

  6. #6
    Member
    Join Date
    Apr 2004
    Posts
    49
    thanks lads.

    worked a treat!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center