Skip to main content
Participating Frequently
June 10, 2012
Answered

Calling a javascript function in Value attribute of param

  • June 10, 2012
  • 1 reply
  • 4381 views

Hi,

I want to set a TLF text field in SWF file through HTML page. So I used flashvar, by calling a javascript function for it attribute "value" as follows.

<param name=FlashVars value="'+ SetFlashMovieParam() +'" id="message" />

SetFlashMovieParam()  is a javascript function as follows.

function SetFlashMovieParam() {                       

     document.getElementById("message").setAttribute("value", "msgText=Start");

}

Even though this doesn't work, when I set the text value directly to "value" attribute, it worked.

<param name=FlashVars value="msgText=Here%20is%20the%20text" id="message" />

I think this is because a syntax error in javascript function calling in param tag. Can anyone help to call that function correctly...

Thanks.

This topic has been closed for replies.
Correct answer Ned Murphy

Normally when you have any executable code nested in html code you have to identify that section accordingly.  In the case of javascript you surround it with <script> tags.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
June 10, 2012

Normally when you have any executable code nested in html code you have to identify that section accordingly.  In the case of javascript you surround it with <script> tags.

watrucAuthor
Participating Frequently
June 10, 2012

Yes, javascript function is surrounded by <script> tag. Here is the full HTML code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

          <head>

                    <title>Face</title>

                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

   <script language="javascript">

 

                                   // Set parameters to send to SWF file

                                   function SetFlashMovieParam() {

                                                  document.getElementById("message").setAttribute("value", "msgText=Start");

                                   }

 

                    </script>

          </head>

          <body bgcolor="#CC99CC">

                    <div id="flashContent">

            <object type="application/x-shockwave-flash" data="Face.swf" width="550" height="400" id="flash">

                <param name="movie" value="Face.swf" />

                <param name="quality" value="high" />

                <param name="bgcolor" value="#ffffff" />

                <param name="play" value="true" />

                <param name="loop" value="true" />

                <param name="wmode" value="window" />

                <param name="scale" value="showall" />

                <param name="menu" value="true" />

                <param name="devicefont" value="false" />

                <param name="salign" value="" />

                <param name="allowScriptAccess" value="sameDomain" />

                <!-- Set parameters to send to SWF file -->

                <param name=FlashVars value="'+ SetFlashMovieParam() +'" id="message" />

                <a href="http://www.adobe.com/go/getflash">

                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />

                </a>

            </object>

                    </div>

          </body>

</html>

Ned Murphy
Legend
June 10, 2012

The function might be, but the call to it is not.... SetFlashMovieParam()