Javascript inside struts

Discussion in 'Java' started by =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=, Jan 29, 2007.

  1. Hello,

    I've been trying to figure something out for the past few days and I
    can't seem to pinpoint what I'm doing wrong.

    I've been trying to call javascript from inside a <logic:equal>, but
    it doesn't seem to work like I want.

    I've tried calling an alert('hello'); to test out if my call worked
    correctly, and it does, but when I call my own javascript functions
    that I create in the html/head, they don't seem to get executed. Any
    idea why (except disbaleCif() which I call through onload)?

    Here's a snippet of code:

    <html>
    <head>
    <link REL="stylesheet" HREF="css/bear.css" TYPE="text/css">
    <script type="text/javascript">
    function disableCif()
    {
    document.ManageKQADocumentForm.cifType1.disabled="true";
    document.ManageKQADocumentForm.cifType2.disabled="true";
    document.ManageKQADocumentForm.cifType3.disabled="true";
    }

    function enableCifType1()
    {
    document.ManageKQADocumentForm.cifType1.disabled="false";
    }

    function enableCifType2()
    {
    document.ManageKQADocumentForm.cifType2.disabled="false";
    }

    function enableCifType3()
    {
    document.ManageKQADocumentForm.cifType3.disabled="false";
    }
    </script>
    </head>
    <body class="MainBody" onload="javascript:disableCif();">
    <logic:iterate id="cifType" property="checkItemFormTypes"
    name="manageKQADocumentTO">
    <logic:equal value="1" name="cifType">
    <script> alert('hello'); </script>
    </logic:equal>
    <logic:equal value="2" name="cifType">
    <script> enableCifType2(); </script>
    </logic:equal>
    <logic:equal value="3" name="cifType">
    <script> enableCifType3(); </script>
    </logic:equal>
    </logic:iterate>

    Regards
    Jean-Francois Michaud
    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=, Jan 29, 2007
    #1
    1. Advertising

  2. =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=

    ceasaro Guest

    How does the generated html page look like? if you view the source
    from you're browser does it show the write javascript? If so you're
    issue is not the concerning the struts framework but you should debug
    the javascript it self. Maybe the browser you use is very strict in
    how to use javascript.

    On Jan 29, 5:25 pm, "Jean-François Michaud" <>
    wrote:
    > Hello,
    >
    > I've been trying to figure something out for the past few days and I
    > can't seem to pinpoint what I'm doing wrong.
    >
    > I've been trying to call javascript from inside a <logic:equal>, but
    > it doesn't seem to work like I want.
    >
    > I've tried calling an alert('hello'); to test out if my call worked
    > correctly, and it does, but when I call my own javascript functions
    > that I create in the html/head, they don't seem to get executed. Any
    > idea why (except disbaleCif() which I call through onload)?
    >
    > Here's a snippet of code:
    >
    > <html>
    > <head>
    > <link REL="stylesheet" HREF="css/bear.css" TYPE="text/css">
    > <script type="text/javascript">
    > function disableCif()
    > {
    > document.ManageKQADocumentForm.cifType1.disabled="true";
    > document.ManageKQADocumentForm.cifType2.disabled="true";
    > document.ManageKQADocumentForm.cifType3.disabled="true";
    > }
    >
    > function enableCifType1()
    > {
    > document.ManageKQADocumentForm.cifType1.disabled="false";
    > }
    >
    > function enableCifType2()
    > {
    > document.ManageKQADocumentForm.cifType2.disabled="false";
    > }
    >
    > function enableCifType3()
    > {
    > document.ManageKQADocumentForm.cifType3.disabled="false";
    > }
    > </script>
    > </head>
    > <body class="MainBody" onload="javascript:disableCif();">
    > <logic:iterate id="cifType" property="checkItemFormTypes"
    > name="manageKQADocumentTO">
    > <logic:equal value="1" name="cifType">
    > <script> alert('hello'); </script>
    > </logic:equal>
    > <logic:equal value="2" name="cifType">
    > <script> enableCifType2(); </script>
    > </logic:equal>
    > <logic:equal value="3" name="cifType">
    > <script> enableCifType3(); </script>
    > </logic:equal>
    > </logic:iterate>
    >
    > Regards
    > Jean-Francois Michaud
    ceasaro, Jan 29, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Katie Wright
    Replies:
    8
    Views:
    4,207
    Andrea Desole
    Jan 7, 2005
  2. sin
    Replies:
    3
    Views:
    712
    Sudsy
    Feb 22, 2004
  3. David Dorward
    Replies:
    1
    Views:
    2,110
    Isofarro
    Jun 28, 2003
  4. spallared
    Replies:
    3
    Views:
    9,324
    david.karr
    May 5, 2007
  5. Jean-François Michaud

    Javascript inside struts

    Jean-François Michaud, Jan 29, 2007, in forum: Javascript
    Replies:
    5
    Views:
    486
    Jean-François Michaud
    Jan 29, 2007
Loading...

Share This Page