A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [AS2] Search field with link in answer field

  1. #1
    Member
    Join Date
    Feb 2005
    Posts
    81

    [AS2] Search field with link in answer field

    Hello all,
    here's what I want to do: I need a simple CV search function for a small site. There will be two fields: on the first field the user will input a Name or Surname and on the second field the script should return one or more results taken from a pool of names + surnames that should be clickable links to the respective .htm page of each cv. Is this possible? From what I've seen people use the replies in the second field as simple text and not as links... Any tips are welcome, thanks.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    for clickable links, make use of asfunction -
    PHP Code:
    // assuming the results can be fed into an array
    // that defines the name and the link (see below)
    arr = [
    {
    nme:"bob",link:"bob.htm"},
    {
    nme:"ben",link:"ben.htm"},
    {
    nme:"tom",link:"tom.htm"}];

    resultsTxt.html true// instance name of dynamic textfield

    for(var n=0;n!=arr.length;n++){
    resultsTxt.htmlText +=
    "<a href='asfunction:linkFunc,"+arr[n].link+"'>"+arr[n].nme+"</a>"
    }

    function 
    linkFunc(param){
    trace(param);
    //getURL(param,"_blank");
    }; 

  3. #3
    Member
    Join Date
    Feb 2005
    Posts
    81
    this looks real neat and easy to update but I can't seem to make it work. Can you please have a look at the attached .fla? I had to change resultsTxt.html to resultsTxt because Flash wouldn't let me use it as instance name...
    Attached Files Attached Files

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    cannot open your fla here in Flash 8.

    note the instance name is - resultsTxt

    the html property of the textfield is set with

    resultsTxt.html = true;

    i have attached my test file - Flash 8 - AS 2
    Attached Files Attached Files

  5. #5
    Member
    Join Date
    Feb 2005
    Posts
    81
    Ah ok, I see what you mean. Thanks for your reply but what I want is a bit different from that. I want one input text field where the visitor of the site types a name (Ben, Jones or Ben Jones) and when they click on a submit button the full name (Ben Jones) appears inside a dynamic text field below with a clickable link that when pressed takes them to a page like benjones.htm. If no input text matches any name in a given list, there should be a non linkable text appearing in the dynamic text field (something like "no results found"). I resaved the above movie as Flash 8 [AS2] and tried to somehow trigger it by putting some actions on the submit button but I now see it's not how you meant it. Is it possible to adapt it to smth like that? Thanks again for your time.
    Attached Files Attached Files

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try this file, it seems to be OK here.

    note: to open a url, remove the comments from the getURL line,
    and either post the files to your server to test, or include your
    development folder to your safe locations in the Settings Manager
    Attached Files Attached Files

  7. #7
    Member
    Join Date
    Feb 2005
    Posts
    81
    It's perfect! Works like a charm! Thanks a lot for all your effort!

  8. #8
    Member
    Join Date
    Feb 2005
    Posts
    81
    Sorry to bug you again but something seems to be preventing it from clicking through. The results display fine below, when I roll over them there is a hand/link cursor change indicating it's a link but when I actually click on them nothing happens. No error, no warning of some sort, nothing. I tested it on Explorer 8 and Mozilla 4.5 with latest Flash plugin installed and the results never click through. I tested the movie you sent me too and it also refuses to click through (tested all both online and locally with dev folder set as trusted)...

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    just to be sure
    you have removed the comment operator on the getURL line ??

    // getURL(param,"_blank");

    should be -
    getURL(param,"_blank");

    ActionScript 2.0 Language Reference
    ActionScript language elements > Operators >
    // line comment delimiter operator

    Indicates the beginning of a script comment.
    Any characters that appear between the comment delimiter (//)
    and the end-of-line character are interpreted as a comment and
    ignored by the ActionScript interpreter.

  10. #10
    Member
    Join Date
    Feb 2005
    Posts
    81
    Quote Originally Posted by a_modified_dog View Post
    note: to open a url, remove the comments from the getURL line


    gah! you already said so up there, for some reason I missed that . Commented out and works as planned, thanks again!

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