Skip to main content
December 30, 2013
Answered

pass query id into pop up window

Hi,

i want to be able to pass the id from the query into the popup window but not sure how to do it, would you please help me with this? - thanks

code below (A) working fine with open the pop up detail page but din't know how to passs an id into detail page.

<!----A--->

  <script>

function openWin()

{

window.open("detail.cfm","_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

}

</script>

<cfset foo = querynew('id_int,aNo_var,Renew,Cancel')>

   <cfloop query="getOrderHist">

      <cfset queryaddrow(foo)>

            <cfset querysetcell(foo,'id_int',getOrderHist.id_int)>

            <cfset querysetcell(foo,'aNo_var',getOrderHist.aNo_var)>

                    <cfset querysetcell(foo,'Renew','<a href="javascript: void(0);" onclick="openWin()">view</a>')>

   </cfloop>

<!---B--->

I try to call the page directly such as below but got an error for  "invalid character"

<cfset foo = querynew('id_int,aNo_var,Renew,Cancel')>

   <cfloop query="getOrderHist">

      <cfset queryaddrow(foo)>

            <cfset querysetcell(foo,'id_int',getOrderHist.id_int)>

            <cfset querysetcell(foo,'aNo_var',getOrderHist.aNo_var)>

    <cfset querysetcell(foo,'Renew','<a href="javascript: void(0);" onclick="window.open("detail.cfm?id=#id#","_blank");>renew</a>')>

   </cfloop>

    This topic is closed to new replies. Start a new post to keep the conversation going.
    duncancummingCorrect answer
    Participating Frequently
    December 31, 2013

    you have an 'openWin' function, but then you're trying to add inline JS to do the same thing.  I assume that later on you're looping over your 'foo' query outputting these links to renew.  In which case I'd want to simply pass either a URL or just the ID into the openWin function.  Much simpler than trying to add dynamic JS into a query cell.

    I'm slightly confused as well why you're creating a new query, foo, when you already have the query getOrderHist which seems to have everything you need.

    function openWin(id) {

        window.open("detail.cfm?id=" + id, "_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

    }

    <cfoutput query="getOrderHist">

        ID: #getOrderHist.id_int#<br>

        aNo: #getOrderHist.aNo_var#<br>

        <a href="" onclick="openWin(#getOrderHist.id_int#); return false;">Renew</a><br>

    </cfoutput>

    2 replies

    duncancummingCorrect answer
    Participating Frequently
    December 31, 2013

    you have an 'openWin' function, but then you're trying to add inline JS to do the same thing.  I assume that later on you're looping over your 'foo' query outputting these links to renew.  In which case I'd want to simply pass either a URL or just the ID into the openWin function.  Much simpler than trying to add dynamic JS into a query cell.

    I'm slightly confused as well why you're creating a new query, foo, when you already have the query getOrderHist which seems to have everything you need.

    function openWin(id) {

        window.open("detail.cfm?id=" + id, "_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

    }

    <cfoutput query="getOrderHist">

        ID: #getOrderHist.id_int#<br>

        aNo: #getOrderHist.aNo_var#<br>

        <a href="" onclick="openWin(#getOrderHist.id_int#); return false;">Renew</a><br>

    </cfoutput>

    Translate
    December 31, 2013

    worked, thanks millions

    Translate