JavaScript variable to ColdFusion variable

Posted by Alexander on Stack Overflow See other posts from Stack Overflow or by Alexander
Published on 2010-01-30T15:58:42Z Indexed on 2010/04/07 13:13 UTC
Read the original article Hit count: 587

I have a tricky one.

By means of a <cfoutput query="…"> I list some records in the page from a SQL Server database.

By the end of each line viewing I try to add this in to a record in a MySQL database. As you see is simple, because I can use the exact variables from the output query in to my new INSERT INTO statement.

BUT: the rsPick.name comes from a database with a different character set and the only way to get it right into my new database is to read it from the web page and not from the value came in the output query.

So I read this value with that little JavaScript I made and put it in the myValue variable and then I want ColdFusion to read that variable in order to place it in my SQL statement.

 <cfoutput query="rsPick">
  <tr>
    <td>#rsPick.ABBREVIATION#</td>
    <td id="square"> #rsPick.name# </td>

    <td>#rsPick.Composition#</td>
    <td> Transaction done...
      <script type="text/javascript">
        var myvalue = document.getElementById("square").innerHTML
      </script>
    </td>

  <cfquery datasource="#Request.Order#">
     INSERT INTO products (iniid, abbreviation, clsid, cllid, dfsid, dflid, szsid, szlid, gross, retail, netvaluebc, composition, name)
     VALUES ( #rsPick.ID#, '#rsPick.ABBREVIATION#', #rsPick.CLSID#, #rsPick.CLLID#, #rsPick.DFSID#, #rsPick.DFLID#, #rsPick.SZSID#, #rsPick.SZLID#, #rsPick.GROSSPRICE#, #rsPick.RETAILPRICE#, #rsPick.NETVALUEBC#, '#rsPick.COMPOSITION#','#MYVALUE#' )
  </cfquery>
 </tr>
</cfoutput>

© Stack Overflow or respective owner

Related posts about coldfusion

Related posts about JavaScript