Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Changing bean message without reloading page

Posted on 2005-02-25
8
Medium Priority
?
312 Views
Last Modified: 2010-04-01
hi!

I am trying to change bean message without reloading page upon button click event. Is there any way of doing it?
++++++++++
<table align="center" width="25%" cellspacing="0" cellpadding="0">
      <tr>
       <th span class="entrycolor"><bean:message  key="firstentry" /></span></th>
      </tr>
</table>
++++++++++++
Or, is there any way of changing font and color of  html:text value just like bean message?
thanks,
0
Comment
Question by:dkim18
  • 3
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
bloodredsun earned 200 total points
ID: 13407868
To both questions:

You could do it via some JavaScript and the onChange event handler.

Remember, the tags are compiled to HTML so you can write JavaScript to alter this, the same way you could change any code.
0
 
LVL 7

Assisted Solution

by:lhankins
lhankins earned 200 total points
ID: 13411543
Add an id entry to your span and an onclick handler, then you can use javascript to find the dom element and change the CSS class, for example:

---------------------------------------------------------------------------------------------------------------------------------------------
<!---HTML -->
<table align="center" width="25%" cellspacing="0" cellpadding="0">
     <tr>
      <th> <span id="firstEntrySpan" onclick="handleSpanClick()" class="entrycolor"><bean:message  key="firstentry" /></span></th>
     </tr>
</table>


<!-- JS Function to swap CSS class onclick -->
<script type="text/javascript">
function handleSpanClick()
{
   var span = document.getElementById("firstEntrySpan");

   if (span.className == "entrycolor")
       span.className = = "highlightedcolor";
   else
      span.className = "entrycolor";
}
</script>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Of course you'll want to define a new css class as well called "highlightedcolor", something like :

<style type="text/css">

*.highlightedcolor
{
   background-color: yellow;
   color:black;
}
</style>
0
 
LVL 7

Expert Comment

by:lhankins
ID: 13411566
here's a fully functional example, cut-n-paste locally and play with it :

----------------------------



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

   <title>test</title>

   <style type="text/css">
   *.entrycolor {
      background-color: white;
      color: black;
   }

   *.highlightedcolor {
      background-color: yellow ;
      color: black;
   }

   </style>

   <script type="text/javascript">
   function handleSpanClick(anElement)
   {
      if (anElement.className == "entrycolor")
      {
         anElement.className = "highlightedcolor";
      }
      else
      {
         anElement.className = "entrycolor";
      }
   }
   </script>


</head>

<body>

<div class="outer">
   <div class="floatRight">
      <table>
         <tr>
            <td><span class="entrycolor" onclick="javascript:handleSpanClick(this);">entry 1</span></td>
         </tr>
         <tr>
            <td><span class="entrycolor" onclick="javascript:handleSpanClick(this);">entry 2</span></td>
         </tr>
         <tr>
            <td><span class="entrycolor" onclick="javascript:handleSpanClick(this);">entry 3</span></td>
         </tr>
      </table>
   </div>
</div>
</body>

</html>
0
 
LVL 7

Expert Comment

by:lhankins
ID: 13411570
(ignore the div stuff there, that's left over from a previous testbed...)
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13622467
split between lhankins  and bloodredsun
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The deadly train derailment that occurred recently in DuPont, Washington, raises a lot of questions. It was a new route, the first trip tested with passengers, and the train was travelling at 50 mph over the zone’s speed limit. Could IoT play a role…
Ready to kick start your career in 2018? Add app developer skills to your resume. January’s Course of the Month features Android App Development training with hands-on learning.  Read on to learn why these skills are important.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

580 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