Onlick and Passing varible

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default Onlick and Passing varible

    I have the page: one textbox, one button using Onclick. User enter name from
    textbox then click "Go button", pop-up page open and display name. I want able
    to pass the value from the txtbox to the pop-up page so i can filter down for
    my search

    <script language="JavaScript">

    function lookup(srchVal, returnTo) {
    var url = "ldaplookup.cfm?name=" + srchVal + "&ret=" + returnTo;
    var lt = (screen.width - 490) / 2;
    var up = (screen.height - 175) / 2;
    window.open(url, "LDAP", "width=540," + "height=175," + "left=" + lt +
    ",top=" + up + " scrollbars, resizable, alwaysRaised", "False");
    }

    function addName(userinfo) {
    if(userinfo != "") {
    var infoArray = userinfo.split("|");
    document.frm.Name.value = infoArray[0];
    document.frm.UserID.value = infoArray[1];
    }
    }</script>

    =============================
    FORM.CFM
    =============================
    Name: <input type="text" name="RequestorName">&nbsp;
    <script language="JavaScript">document.write('<input type="button"
    value="Lookup Name" name="x500Lookup"
    onclick=lookup(document.frm.Name.value,"addName")> </td>');</script>

    ==============================
    ldaplookup.cfm
    ==============================

    <cfldap name="results"
    server="X500.JSC.NASA.GOV"
    action="QUERY"
    attributes="roomnumber,userClass,mail,telephonenum ber, sn"
    filter="(sn ~='#Name#')"
    sort="sn Asc"
    scope="Subtree"
    start="ou=whtg ,o=administration,c=us">
    <cfoutput>#Name#</cfoutput><br>

    ERROR:
    Variable NAME is undefined.

    newcf Guest

  2. Similar Questions and Discussions

    1. Varible clearance, mouse/keyboard
      I seem to be having problems with my login scripts. I have mentioned this here before, but have some more ideas i would like to run past you all....
    2. passing varible
      How do I pass the automatic name from page to page to find out the value. Here is my explanation. I have index.cfm with all the radio boxes for...
    3. 2 onlick events?
      I have a clickable image that I would like to convert into a server control imagebutton accessing a server-side onClick event and a client-side...
    4. Varible Problem
      Hi, I have a problem with the structure of my website which is causing problem with passing variables between functions, even when declared as...
    5. Seting A Flash Varible with a URL
      Hey all, I posted this question to data_intergration and got no responce, thought this might be a better forum for it. I need to set a varible...
  3. #2

    Default Re: Onlick and Passing varible

    > .... onclick=lookup(document.frm.Name.value,"addName")> </td>');</script>

    Make sure the reference to the textbox value is correct.

    1) Is your form actually named "frm" ?
    2) Is the textbox name "RequestorName" or "Name". Make sure to use the
    correct case.

    Also, you should scope the variable in the "ldaplookup.cfm" page.

    <cfoutput>#url.Name#</cfoutput><br>



    mxstu Guest

  4. #3

    Default Re: Onlick and Passing varible

    msxtu,
    Thanks for point that out. I acutally copy and paste.

    Yes, the form name is frm and the texbox name is RequestorName
    Thanks
    newcf Guest

  5. #4

    Default Re: Onlick and Passing varible

    It worked fine for me.



    <script language="JavaScript">

    function lookup(srchVal, returnTo) {
    var url = "ldaplookup.cfm?name=" + srchVal + "&ret=" + returnTo;
    var lt = (screen.width - 490) / 2;
    var up = (screen.height - 175) / 2;
    window.open(url, "LDAP", "width=540," + "height=175," + "left=" + lt +
    ",top=" + up + " scrollbars, resizable, alwaysRaised", "False");
    }
    </script>
    =============================
    FORM.CFM
    =============================
    <form name="frm">
    Name: <input type="text" name="RequestorName">&nbsp;
    <script language="JavaScript">document.write('<input type="button"
    value="Lookup Name" name="x500Lookup"
    onclick=lookup(document.frm.RequestorName.value,"a ddName")></td>');</script>
    </form>

    =============================
    LDAPLOOKUP.CFM
    =============================
    <cfoutput>#url.Name#</cfoutput><br>

    mxstu Guest

  6. #5

    Default Re: Onlick and Passing varible

    msxtu,

    Thanks alot. I can't try it from home, will try it tomorrow and let you know.

    what I try to do is passing the name from the textbox into my filter from
    cfldap query. sn is the lname, and given name is the fname. User might enter :
    lname, fname OR lname. I also have to specify two attributes for starts.
    Please tell me if i have the incorect systax.

    <cfldap name="results"
    server="X500"
    action="QUERY"
    attributes="roomnumber,userClass,mail,telephonenum ber, sn"
    filter="(|(sn ~=#RequestorName#) (givenname ~=#RequestorName#) )"
    sort="sn Asc"
    scope="Subtree"
    start="(&(ou=whtg ,o=administration,c=us) (ou=jku,o=administration,c=us))"


    newcf Guest

  7. #6

    Default Re: Onlick and Passing varible

    You may need to parse the #url.RequestorName# value to extract a first or last
    name, but the concept of passing the value to the popup window is fine. I
    haven't used ldap in a while, so I would check your ldap documentation for the
    right syntax :-)

    mxstu Guest

  8. #7

    Default Re: Onlick and Passing varible

    msxtu,

    I still getting the error. the output is <cfoutput>#url.RequestorName#</cfoutput> not <cfoutput>#url.Name#</cfoutput>. RequestorName is the name for the textbox
    newcf Guest

  9. #8

    Default Re: Onlick and Passing varible

    Did you try the exact code I posted? Or did you modify it?

    ....var url = "ldaplookup.cfm?name=" + srchVal + "&ret=" + returnTo;
    On the "ldapLookup.cfm" page make sure you are reference the url variable that
    was passed, and not the name of the text box in the main form.



    mxstu Guest

  10. #9

    Default Re: Onlick and Passing varible

    I've figured out. Thanks
    newcf Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139