Hello

maybe it is a bit too complicated what I am doing. Therefore I first
describe what I need, then what I have done, and then the problem I have...

I would like to have a form that has two radio buttons yes/no, that on click
either show another subset of questions or hide them. The subset of
questions contain html:text, html:radio and html:select/html:options
elements.

I did this by defining a DIV element inside a table-td, with a certain id.
The onclick functions of the radio buttons either call a change-layercontent
or a change-layervoid javascript function. These javascript functions have
different sections for the different kind of browsers but basically either
load a preset string into the div-layer-documentsection or an empty string.
Above the java functions, still inside script tags, the empty string and the
preset string are defined. The preset string will be made up by struts html:
elements. To avoid conflicts with quotes, the struts elements use double
quotes, the javascript single quotes. Around each struts element on a new
line, single quotes have been added, plus a +sign to connect the next line.
In that way, all the struts element will be part of the javascript string
variable.

Now the problem: the html:options element writes it output to several lines.
Only at the beginning of the first line, and at the end of the last line are
quotes now :-(. The javascript does not recognise it as a string variable.

I will add a code piece below:


       <td><bean:message key="prompt.CarDriverPage.otherDriver"/></td>
                         <td size="10">
                                        <bean:message key="TRUE"/>
                                        <html:radio onclick="change_layercontent();" 
property="otherDriver"
value="true" />
                                        <bean:message key="FALSE"/>
                                        <html:radio onclick="change_layervoid();" 
property="otherDriver"
value="false" />
                        </td>
    </tr>
    <tr><td>
                        <div id="secondlevel"></div>
    </td></tr>
<SCRIPT>
var secondlevellayer;
var msgstringvoid=''
var msgstring=''
+ '    <table><tr>'
+ '              <td><h5><bean:message
key="prompt.CarDriverPage.sex2"/></h5></td></tr>'
+ '      <tr><td>
+ '                             <html:select property="sex2"><html:options 
collection="sexList"
property="name" labelProperty="label"/></html:select>'
+ '                      </td></tr>'
+ '    </tr></table>';

function printCont(var1) {
        alert(var1);
}

function change_layercontent(){
  if(document.layers){
    //thisbrowser="NN4";
    secondlevellayer = document.layers["secondlevel"];
    secondlevellayer.document.open();
    secondlevellayer.document.write(msgstring);
    secondlevellayer.document.close();
  }

  if(document.all){
    //thisbrowser="ie"
    secondlevellayer = document.all["secondlevel"];
    secondlevellayer.innerHTML=msgstring;
  }

  if(!document.all && document.getElementById){
    //thisbrowser="NN6";
    secondlevellayer = document.getElementById("secondlevel");
    secondlevellayer.innerHTML =msgstring;
  }
}

function change_layervoid(){
  if(document.layers){
    //thisbrowser="NN4";
    secondlevellayer = document.layers["secondlevel"];
    secondlevellayer.document.open();
    secondlevellayer.document.write(msgstringvoid);
    secondlevellayer.document.close();
  }

  if(document.all){
    //thisbrowser="ie"
    secondlevellayer = document.all["secondlevel"];
    secondlevellayer.innerHTML=msgstringvoid;
  }

  if(!document.all && document.getElementById){
    //thisbrowser="NN6";
    secondlevellayer = document.getElementById("secondlevel");
    secondlevellayer.innerHTML =msgstringvoid;
  }
}

//change_layercontent();
change_layervoid();

</SCRIPT>


Hope someone can help ...

Regards, Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to