Javascript function undefined error

Hi developers,
I am generating a html file on the fly using a perl program. The main form to be used is generated by a javascript function called loadPage(). loadPage writes the <form> <input type="checkbox"> blah..</form> into the document by using document.write When the checkbox is unchecked, a javascript function called delFromList is called. This function is generated when the html is generated(by the perl program). The problem now is that the form comes out well but when I uncheck the checkbox, the javascript error says delFromList undefined...the same problem occurs for each function call...what am I missing here...any help will be highly appreciated...
tia.
vish
PS: the sample html is inlined below
Content-type: text/html
     <html>
     <head>
     <title>Level Refinement</title>
     <script Language=JavaScript>
function delFromList(box) {
blah blah....
function addToList(box) {
blah blah....
....and many other functions...all function that are used are defined....
function loadPage()
                    document.write("<form name=layout action=\"http://software.somesite.com:81/cgi-bin/parser.pl\" Method=post>");
          document.write("<INPUT TYPE=CHECKBOX NAME=\"European\" VALUE=\"European\" onClick=\"if(this.checked){addToRankList(this)}else{delFromRankList(this)}\" CHECKED>European<BR>");
          document.write("<INPUT TYPE=CHECKBOX NAME=\"Canadian\" VALUE=\"Canadian\" onClick=\"if(this.checked){addToRankList(this)}else{delFromRankList(this)}\" CHECKED>Canadian<BR>");
          document.write("<INPUT TYPE=CHECKBOX NAME=\"Japanese\" VALUE=\"Japanese\" onClick=\"if(this.checked){addToRankList(this)}else{delFromRankList(this)}\" CHECKED>Japanese<BR>");
          document.write("<h4>Rank your preferences:<ul type=circle><li> Select the attribute to move<li> Use the \"Move Up\" and \"Move Down\" buttons to move the attribute ranking HIGHER and LOWER respectively.<br></h4>");
          document.write("<div align=center><center><table width=100% border=1><tr><td width=30% valign=top align=center>Ranking (High to Low)<br><select name=col1 size=10 onChange=checkSelectCol1()>");
          document.write("<option>European");document.write("<option>Canadian");document.write("<option>Japanese");               
          document.write("</select><p>");
          document.write("<INPUT TYPE=button value=\"Move Up\" size=4 onClick=javascript:col1Up(document.layout.col1)>");
          document.write("<INPUT TYPE=button value=\"Move Down\" size=4 onClick=javascript:col1Down(document.layout.col1)>");     
          document.write("</td></tr></table></div><br>");
          document.write("<INPUT TYPE=button value=\"Next\">");     
          document.write("</form>");
     </script>
</head>
     <body onload="loadPage()">
     </body>
     </html>

As mentioned above javascript and java are 2 different thigns. How ever after looking at your code I would have to guess that you missed a '{' or '}' some where in you actual code. Other than some minor html syntax errors I realy didn't see anything wrong with the code above. But since you didn't post the actual code it hard to say if fixing the few minor errors would make any diff. I'm going with missed curly braces.
Ron_W

Similar Messages

  • ExternalInterface Call Javascript Array to AS2 throwing undefined error

    I need to pass various (tracking) IDs to a .swf.  the IDs are in an array like this =
    <script type="text/javascript">
    function getImpID() {
    var medID={impID:'12345',pvID:'677890',exID:'654332'};
    return medID;
    function thisMovie(banner) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[banner]
        else {
            return document[banner]
    window.onload=getImpID;
    </script>
    Right now the AS2 I have is:
    import flash.external.*;
    System.security.allowDomain(sourceDomain)
    var allID:String = ExternalInterface.call.apply("getImpID");
    function getIDs(){
              var impID:Number;
              var pvID:Number;
              var exID:Number;
              var id_arr:Array = allID.split(",");
        _root.id_test.text = impID;
    getIDs();
    Basically what I need is to split the three ID's from the javascript so that I can append them with various URL clickTags in the AS.  Main issue I have is the 'undefined' error, so I'm going out on a limb here that the AS2 I have doesn't do anything right now of value.  Biggest head scratcher for me is, if I have the IDs in an array in the javascript (medID) how to get them not only properly into Flash but to separate them into their separate IDs. 
    Any suggestions would be greatly appreciated.
    Thanks!

    Forgot to reply, your guidance helped in solving the riddle =
    actionscript:
    function idTag(){
              getID = Object(ExternalInterface.call("getImpID"));
              getID.toString();
      //_root.id_test.text = getID;
    idTag();
    javascript
    <script type="text/javascript">
    function getImpID() {
              var getID=['impID=8910424942498409873&pvID=8910423767061585831'];
              thisMovie("banner").getID;
              return getID;
    function thisMovie(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[movieName]
        else {
            return document[movieName]
    </script>
    worked like a charm!

  • Javascript in AIR, bind function undefined

    I'm creating an HTML/Javascript based AIR app, but getting the error that 'bind' (a standard JavaScript function) is undefined.
    Since bind is being used in a 3rd party library this pretty much kills my hopes of using it unless I wanted to hack through that library, which I don't. I guess this is because the version of WebKit embedded in AIR is not able to support bind for whatever reason (I'm publishing to AIR 13.0)
    But I'm wondering if the correct approach is to create an ActionScript based app that uses StageWebView? Is StageWebView using a more updated version of WebKit?
    Thanks

    if I place all of the commands into a single <script> element, the problems go away but it's quite a limitation to only have one document.write in the document. I plan to eventually script re-formatting of the Metadata data so that I can do something like this:
    <p>version name</p>
    <p>caption line 1 [return]
    caption line 2</p>
    <p>aperture: f2.8</p>
    becomes:
    <h3 class="version_name">version name</h3>
    <p>caption line 1</p>
    <p>caption line 2</p>
    <p class="exif">aperture: f2.8</p>

  • Undefined in alert of JavaScript Function

    Dear All
    i have the below source of my jsf page, it contains java script small function (to access input text component) & get its value and show it in alert, but i am facing "*undefined*" instead of the value in the alert , please advise
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <af:document title="untitled2.jsf" id="d1" binding="#{backingBeanScope.backing_untitled2.d1}">
    <af:messages id="m1" binding="#{backingBeanScope.backing_untitled2.m1}"/>
    <af:form id="f1" binding="#{backingBeanScope.backing_untitled2.f1}">
    *<af:resource type="javascript">*
    *function checkval() {*
    var val = document.getElementById('it2');
    alert(val.value);
    *</af:resource>*
    <af:panelStretchLayout topHeight="50px" id="psl1" binding="#{backingBeanScope.backing_untitled2.psl1}">
    <f:facet name="top">
    *<af:inputText value="#{bindings.EmployeeId.inputValue}" label="#{bindings.EmployeeId.hints.label}"*
    *required="#{bindings.EmployeeId.hints.mandatory}"*
    *columns="#{bindings.EmployeeId.hints.displayWidth}"*
    *maximumLength="#{bindings.EmployeeId.hints.precision}"*
    *shortDesc="#{bindings.EmployeeId.hints.tooltip}" id="it2"*
    *binding="#{backingBeanScope.backing_untitled2.it2}" clientComponent="true">*
    <f:validator binding="#{bindings.EmployeeId.validator}"/>
    <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeeId.format}"/>
    <f:facet name="context"/>
    </af:inputText>
    </f:facet>
    <f:facet name="center">
    <af:panelGroupLayout layout="scroll" id="pgl1" binding="#{backingBeanScope.backing_untitled2.pgl1}">
    <af:inputText label="Label 1" id="it1" binding="#{backingBeanScope.backing_untitled2.it1}"
    clientComponent="true" autoSubmit="true"/>
    *<af:commandButton text="commandButton 1" id="cb1"*
    *binding="#{backingBeanScope.backing_untitled2.cb1}" clientComponent="true"*
    *partialSubmit="true">*
    *<af:clientListener method="checkval" type="action"/>*
    </af:commandButton>
    </af:panelGroupLayout>
    <!-- id="af_one_column_header_stretched" -->
    </f:facet>
    </af:panelStretchLayout>
    </af:form>
    </af:document>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_untitled2-->
    </f:view>

    Dear All
    i made all the above solutions but still facing the same error, but i need another help, i found in oracle doc regarding this, the below statement
    Absolute expressions use the fully qualified JSF client ID (meaning, prefixed with the IDs of all NamingContainer components that contain the component) with a leading NamingContainer.SEPARATOR_CHAR character
    You can determine whether or not a component is a naming container by reviewing the component tag documentation. The tag documentation states whether a component is a naming container.
    so can any one help me to know the a naming container list of jsf components for 11.1.2.0 JSF 2.0 ?
    thanks
    Edited by: Oracle ITself on Sep 5, 2011 12:51 AM

  • Error in calling a javascript function

    Hi
    Below is a code from my HTML file...
    <html>
    <head>
    <script language="javascript" >
    function try()
    alert("hi");
    </script>
    </head>
    <body>
    <input type="button" value="Hello world!"
    onclick='try();'>
    </body>
    </html>while running page in browser i m getting error :
    line: 12
    char: 4
    error: expected "{"
    I understand that this is not a java problem but please help.
    thanx
    Edited by: money321 on Feb 5, 2008 6:07 AM

    I know that this is not the right forum, but I'd like peoples' advice on which prep to use for a colonoscopy. The Fleet's Phosphosoda prep is more palatable, and easier and more convenient to take compared to the Colyte (gallon jug) prep, but on the other hand the Colyte prep is safer since it doesn't carry the risk of calcium phosphate precipitates forming in the kidneys potentially causing acute kidney failure, a rare but certainly serious complication. Many thanks in advance.

  • Error referencing a Struts-Form element from a JavaScript function.

    As shown below, when referencing the form element named 'custRegion', from the JavaScript function, I get an error msg - document.forms[0].custRegion has no properties.
    It appears that this form-element, which also is present in the logic tag is not visible - is it because I'm referencing it incorrectly...
    <SCRIPT> function setRegion() { var theRegion= 'Western'
    document.forms[0].custRegion.value=theRegion; } </SCRIPT>
    <logic:iterate id="customer" name="customerForm" property="customers" >
    <html:text name="customer" property="custRegion"/>
    <html:select name="customer" property="custState" size="1" onchange="setRegion()">
    <html:option value="1"> California </html:option>
    <html:option value="2"> Arizona </html:option>
    </html:select>
    </logic:iterate>

    Here's a quick example of what may help you. It simply disables the select box and slides in a new text box. Nevertheless, it shows you that you accessed a struts property by name.
    struts code:
    <html:select property="customerRegion">
            <html:option value="-1">Unknown</html:option>
            <html:option value="0">Western</html:option>
    </html:select>
    //quick & dirty textbox for testing.  you'll probably want <html:text ... here instead.
    <input type="checkbox"
           onclick="disableSelectAddTxt(document.YOUR_FORM['customerRegion'], this.checked)" />
    Check box to replace select pull-down  
          <div id="setTBox"></div>javascript:
    function disableSelectAddTxt(selectBoxName, disableIt)
        var setTBoxName = selectBoxName;
        //alert('You passed me ' +setTBoxName+ ' and' +disableIt);
        selectBoxName.disabled = disableIt;
        var setTBox = document.getElementById("setTBox");
        if (disableSelect == true) {
            setTBox.innerHTML = "<input type=\"text\" name="+setTBoxName+ "size=\"10\">";
        if (disableSelect == false) {
            setTBox.innerHTML = "";
      hope this helps.

  • Getting an "undefined" error when passing a variable to a function using Microsoft Razor

    I am trying to call a function and pass a variable to it. However I get an "undefined" error.
    The code is:
    Layout = "~/_SiteLayout.cshtml";
    Page.Title = "General Information";
    var recID = 3;
    <input type="text" id="rdy">
    <p>
    <a href=""><input type="button" name="button" id="button" value="Next Hypothetical" onclick='reselectState(recID)'></a>
    </p>
    <script>
    function reselectState(recIDx)
    var elem = document.getElementById("rdy");
    elem.value = recIDx;
    var rdy = $("#rdy").val();
    alert(rdy);
    location.href = '/hypothetical.cshtml?recordkey=' + rdy;
    </script>
    It seems to think that the variable "recID" is undefined even though it exists and I assign a value to it.

    Michael,
    Let me ask you this ... Are you trying to pass the value of the Input value? If you are looking for the input value to be .. then I made some changes you can follow...
        var recId = 3;
        <input type="text" id="rdy">
        <p>
            <a href="">@*<input type="button" name="button" id="button" value="Next Hypothetical" onclick='reselectState(recId)'>*@</a>
            <input type="button" name="button" id="button" value="Next Hypothetical" onclick='test()' />
        </p>
        <script>
            function test() {
                var inputValue = document.getElementById("rdy").value;
                reselectState(inputValue);
            function reselectState(recIDx) {
                var elem = document.getElementById("rdy");
                elem.value = recIDx;
                var rdy = $("#rdy").val();
                alert(rdy);
                location.href = '/hypothetical.cshtml?recordkey=' + rdy;
        </script>
    --Thanks,
    Pavan

  • Error when calling a Javascript function loaded as a library

    Hi All,
    I have some javascript functions in a custom js file which is in OA_HTML dir. I have loaded this js library using pageContext.putjavascriptlibrary("ABC","custom.js") in processRequest. When I deploy my code, there is a javascript error in the page. It does not seem to find the javascript function.
    My code in PR is :
    pageContext.putjavascriptlibrary("ABC","custom.js")
    someBean.setOnFocus("javascript: callFunc(this);"); //callFunc(obj) is defined in custom.js
    It works locally when I have my custom.js in myhtml directory. I am getting an error when I deploy the code on to the instance's apps server. Is there something that I am missing?
    Thanks in advance
    Raja

    Raja,
    You can bounce apache , and server cache would be refreshed!I guess then ur updated js function should work. Also,check ur js function works correctly on jdev.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                               

  • JuseJSAssert Error calling selector function: Reference Error:'PIE' is undefined

    Since installing your new version of Adobe Muse yesterday I have not been able to get updated pages to upload to my website.  I have exported the html to my desktop and it looks right there but when I upload it to the website I get the following error message: MuseJSAssert: Error calling selector function: Reference Error:"PIE" is undefined.   I have uploaded only the updated page but then I tried uploading the whole site MANY times and it just is NOT working.  Can I go back to the prior version as I had no problems with it.  PLEASE help!  I have worked on this for two days and am tired of it and need to get my site working properly!  Thanks for your quick response!

    Whats the site URL in question? Are you uploading the site to Business Catalyst or to a third party hosting provider? Did you try uploading all site files through a FTP client like Filezilla? Is that a specific browser/version where the problem occurs?
    Thanks,
    Vinayak

  • The javascript functions are working correctly, but still get scripting error messages

    When you open or run any javascript functions in this form, error messages pop up, but functions work correctly. Anyone that can help me get rid of error messages? Screenshots are attached.

    can you please share the error messages.

  • Problem when calling more than 1 Javascript function

    Hello everybody,
    I am trying to disable fields based on the value in a Select List. There is a table in which values are stored to tell if a field should be disabled for the selected value. I have created an Application Process and a JavaScript function for each field.
    The problem is that only the first function is executed, and the second not.
    I have tried the following:
    onchange="Disable_Dagen(this);Disable_Kg(pThis);"and I have put them together in a parent JavaScript function
    function Disable_Fields(pThis){
    Disable_Kg(pThis);
    Disable_Dagen(pThis);
    }In either case only the first works, so when I change the order then the other one is executed properly.
    Can anyone give me a clue on how to solve this?
    My complete JavaScript definition in the header is as follows:
    (the code in html_DisableOnValue is taken from the example site from Carl Beckstrom)
    <script language="JavaScript" type="text/javascript">
    <!--
    function html_DisableOnValue(pThis,pValue,pThat){
         var lTest;
      if(pThis.nodeName == 'SELECT'){
                   lTest = html_SelectValue(pThis) == pValue;
         }else{
                   lTest = $x(pThis).value == pValue;
         if(pThat){
               for (var i=2;i <= arguments.length; i++){
                          html_disableItem(arguments,lTest)
         return;
    function Disable_Dagen(pThis){
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=AP_RETURN_DISABLE_VAL_DGN',0);
    get.add('AI_AFW_CODE',pThis.value);
    gReturn = get.get();
    get = null;
    //alert('Return waarde is '+ gReturn );
    html_DisableOnValue(pThis,gReturn,'P43_AANTAL_DAGEN');
    function Disable_Kg(pThis){
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=AP_RETURN_DISABLE_VAL_KG',0);
    get.add('AI_AFW_CODE',pThis.value);
    gReturn = get.get();
    get = null;
    //alert('Return waarde is '+ gReturn );
    html_DisableOnValue(pThis,gReturn,'P43_AANTAL_KG');
    function Disable_Fields(pThis){
    Disable_Kg(pThis);
    Disable_Dagen(pThis);
    //-->
    </script>
    In this case the Form Element property is set toonchange="Disable_Fields(this)"
    Thanks, Wouter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Roel,
    Thanks again for your response.
    There is a lot more to Firebug then I had seen before. Now I have turned on the Console and the Script. Initially I saw the following in the Console:
    C is undefined
    $x_disableItem(undefined, true)apex_3_1.js (regel 1)
    html_DisableOnValue(select#P43_AFWIJKING_CODE, "101", "P43_AANTAL_DAGEN")f?p=104:...2606::::: (regel 38)
    Disable_Dagen(select#P43_AFWIJKING_CODE)f?p=104:...2606::::: (regel 51)
    onchange(change )f?p=104:...FPQ%3D%3D (regel 2)
    [Break on this error] var gDebug=true;var gkeyPressTime;var gL...Options;html_SelectValue=$f_SelectValue;When I removed the comments before the 2 Alerts, I only got one alert when I tested it.
    Then I replaced the function call to html_DisableOnValue to $f_DisableOnValue as you suggested, and that did the trick. Now it Works!
    I still don't know why the html_DisableOnValue function doesn't work. I just copied it from the demo site of Carl Beckstrom. Anyway my problem is solved.
    Have a nice weekend, Wouter

  • Call Javascript Function Allow Domain

    It took me a while, but I was finally able to get my flash file to call a javascript function on my webpage. I had to add this as2 code:
    System.security.allowDomain("*");
    This fixed my problem, but it causes a compiler error:
    Scene 1, Layer 'Layer 1', Frame 1, Line 3    1119: Access of possibly undefined property security through a reference with static type Class.
    How do I do allow my domain with as3? I tried Security.allowDomain('*') but that doesn't seem to fix my orginal problem.

    OK it's working now with as3 code. On the webpage I had to wait until the dom was ready before calling the as3 function from javascript. I guess the as2 code was just slowing it down enought to make it work.

  • JSP Array to Javascript function :URGENT HELP

    Hi,
    i have problem in sending array from JSP to Javascript function. if you have any answer please let me know asap.
    Thanks in advance.
    -Priya

    Hi Kurt,
    I have written follow. program . but still I'm getting errors.
    I don't know what I'm doing wrong.
    <HTML>
    <HEAD>
    <SCRIPT>
    function showArray()
         var str = new Array (<%for (int j=0; j<jspstr.length; j++);
         out.print ("\"" + jspstr[j] + "\"" + (j<(jspstr.length-1)?",":""));%>);
         alert ("Total elements received: " + str.length);
         for (j in str)
         alert ("element number " + j + " equals " + str[j]);
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM>
    <%String[] jspstr = {"abc", "def", "ghi", "jkl"};%>
    <SCRIPT>
    showArray();
    </SCRIPT>
    </FORM>
    </BODY>
    </HTML>
    com.ibm.servlet.engine.webapp.WebAppErrorReport: C:\Program Files\IBM\VisualAge for Java\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\_try_xjsp_debug_jspsrc_988535311.java:135: Undefined variable or class name: jspstr
    for (int j=0; j<jspstr.length; j++);
    ^
    C:\Program Files\IBM\VisualAge for Java\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\_try_xjsp_debug_jspsrc_988535311.java:136: Undefined variable: jspstr
         out.print ("\"" + jspstr[j] + "\"" + (j<(jspstr.length-1)?",":""));
         ^
    C:\Program Files\IBM\VisualAge for Java\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\_try_xjsp_debug_jspsrc_988535311.java:136: Undefined variable: j
         out.print ("\"" + jspstr[j] + "\"" + (j<(jspstr.length-1)?",":""));
         ^
    C:\Program Files\IBM\VisualAge for Java\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\_try_xjsp_debug_jspsrc_988535311.java:136: Undefined variable: j
         out.print ("\"" + jspstr[j] + "\"" + (j<(jspstr.length-1)?",":""));
         ^
    C:\Program Files\IBM\VisualAge for Java\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\_try_xjsp_debug_jspsrc_988535311.java:136: Undefined variable or class name: jspstr
         out.print ("\"" + jspstr[j] + "\"" + (j<(jspstr.length-1)?",":""));
         ^
    5 errors
    Thanks,
    -Priya

  • Passing value from javascript function to servlet

    Hello everybody,
    i need to pass parameter from javascript function to servlet.
    what i wrote is :
    function callPopulateServlet(t)
    var h =document.NewRequest.services;
    var y = t.selectedIndex;
    alert(h.options[y].value);
    var id=h.options[y].value;
    <%session.setAttribute("id",id);%> // am getting error at this point
    document.NewRequest.submit();
    with this id am quering values from database through servlet.
    any body knows plz help me.
    thanks,
    anil.

    this is the error am getting
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • How to call a bean method through a javascript function

    I dont discover any problems calling the bean method in this maner:
    <%= helpdesk.data() %>
    But, when I use a Button Onclick= to call the script function and which then is going call my bean method
    an error on the page is reported!
    I have include som code which gives you the idea of what Iam searching for. And is it possible to call
    the bean method without doing from a new jsp page?
    If you have any suggestions to why it doesnt work, please let me know.
    I use Apache Tomcat 4.0
    Best regards Micah.
    <jsp:useBean id='helpdesk' scope='application'
    class='helpdesk.testdb'/>
    <html>
    <head>
    <script language="javascript">
    function broadcast()
    helpdesk.data();
    </script>
    </head>
    <body>
    <input type="button" value="Broadcast" onclick= broadcast()>
    </body>
    </html>

    It's actually quite simple:
    Beans run server-side
    Javascript runs client-side
    So you will never be able to run server-side-code thru the client...

Maybe you are looking for