Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add dinamic value to javascript.

Explorer ,
Sep 30, 2010 Sep 30, 2010

I know that the solution is probably simple, however I can not hanle it since javascript is not really my thing. Now, I just want to add a dynamic value to javascript, for example ID and pass it (on button click) with the same script to previously built Coldfusion page.

here is an example

<cfquery name="test11" datasource="datasource">
SELECT *
FROM database
</cfquery>

<cfset javaDinamicID= #test11.ID# >

and javascript, something like this

<script language="javascript" type="text/javascript">
function testDinamicID() {
req=new XMLHttpRequest(); req.open('GET','/JavaID.cfm?ID='     this part here I cannot handle, how to add a dynamic value here     +1+'&'+'NAME='+aaa,false); req.send(null);
}
</script>

Am I on the right track?

409
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 30, 2010 Sep 30, 2010

pirula08 wrote:

Am I on the right track?

Yup.

You do it just like you would do it to output HTML in a table or something.

<cfoutput query="test11"

     <script language="javascript" type="text/javascript">
        function testDinamicID() {

          req=new XMLHttpRequest(); req.open('GET','/JavaID.cfm?ID=#test11.someID#&'+'NAME='+aaa,false); req.send(null);

        }
     </script>

</cfoutput>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2010 Oct 03, 2010
LATEST

Your answer is 99% accurate.

I just want to create like/dislike buttons like those on youtube, so this was the easy part. Anyway now when i know a little bit more about javascript I'll do my best to handle everything else.

Thanks ilssac

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources