?
Solved

JSP is causing error in my form

Posted on 2006-12-01
5
Medium Priority
?
176 Views
Last Modified: 2010-04-01
I have jsp form with a label and drop down box.

There is a radio button for a user to select their institution U = University T = technical school.    There is a drop down box for ONLY technical students.  It must not appear for university students.  Upon opening, getInst() is checked.  If it is U, disable both the label and drop down box.  Otherwise display them.

The user has the option to change their institution.
If a Univ student decides to change to technical, the drop down box and label must appear.
If a technical student decides to change to univ the drop down box and label must be disabled

enabling and Disabling the dropdown box works fine, the label is not  I don't know why

the label used to work like this
<td align=left><FONT id="label1" class="smallbold">Technical School:</FONT></td>
but when I added
<td align=left><FONT id="label1" class="smallbold"
   <% if (institution.getInst.equals("U")) { %> disabled <%} %> >
it stopped working

Why is this happening? How can I fix it?
If it cannot be fixed, is there another way to resolve it?
Thank you in advance for your help

here is my code
...
<form>

<%
   // U = University T = technical school
   // object inst
%>

//Radio button for technical school or University here, selecting it invokes: xxx(inst)

<tr>
   <td align=left><FONT id="label1" class="smallbold"
      <% if (inst.getInst.equals("U")) { %> disabled <%} %> >Technical School:</FONT>
   </td>            
   <td><select  name="theSchool" id="schoolID" width=10
             <% if (inst.getInst.equals("U")) { %> disabled <%} %> >
               <font class=smallbold>
                  <OPTION VALUE='1'  SELECTED>Winston Churchill school
                  <OPTION VALUE='2' >Margaret Thatcher school
                  <OPTION VALUE='3' >Jon Richards School
              </font>
          </select>
   </td>
</tr>      
...
</FORM>
...  


I also have javascript for a user to select manually select the instituion

function xxxx(inst) {

   var classAttrString = document.all? 'className':'class';

   if (inst == 'U') {
      var theClass="smallbolddisabled";
      document.form.theSchool.disabled=true; // this works ok
      updateLabel(classAttrString, theClass) // not working
   }
   if (inst == 'T') {
      var theClass="smallbold";
      document.form.theSchool.disabled=false; // this works ok
      updateLabel(classAttrString, theClass)  // not working
   }
}

function updateLabel(classAttrString, theClass) {
   // this code used to work
   document.getElementById('label1').setAttribute(classAttrString,theClass,0);      
}




0
Comment
Question by:kngoc7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 400 total points
ID: 18059159
Please try the following, this is found working in IE:

<STYLE TYPE="text/css">
.smallbold {
   // your style
}

.smallbolddisabled {
   // your disabled style
}
</STYLE>

BTW, I guess your label should be the following:

<tr>
   <td align=left><FONT id="label1" class="smallbold<% if (inst.getInst.equals("U")) { %>disabled<%} %>" >Technical School:</FONT>
   </td>

or a better way:
<tr>
   <td align=left><FONT id="label1" class="smallbold<%= (inst.getInst.equals("U"))?"disabled":"" %>" >Technical School:</FONT>
   </td>
0
 

Author Comment

by:kngoc7
ID: 18081852
Thanks for your help, let me test it and get back to you
0
 
LVL 17

Assisted Solution

by:gops1
gops1 earned 400 total points
ID: 18137944
Or else:

<tr  style="display:<% if (inst.getInst.equals("U")) { %> none<%}else{%> ''<%}%>">
   <td align=left><FONT id="label1" class="smallbold" >Technical School:</FONT>
   </td>          
   <td><select  name="theSchool" id="schoolID" width=10>
               <font class=smallbold>
                  <OPTION VALUE='1'  SELECTED>Winston Churchill school
                  <OPTION VALUE='2' >Margaret Thatcher school
                  <OPTION VALUE='3' >Jon Richards School
              </font>
          </select>
   </td>
</tr>  
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question