Solved

I am new to CF, I need to change some html on a page with an onMouseOver or similar event - READ IN PLEASE?

Posted on 2003-11-15
6
178 Views
Last Modified: 2013-12-24
Hi I am new to CF so I don't know if this is possible or not but here goes.

I need to change some html on my page using CF if possible with an onMouseOver type of event. For example I have a form that contains a table with 5 rows, each of the rows displays a different "plan" for the user to choose. When the user rolls over those cells I want some html on the page to "change" or become "visable". I don't want to use javascript if I can help it because the only good way I have found to do this in JS is to use the

document.getElementById().innerHTML

which is limited to only recent browsers. Maybe there is a better way to do it with javascript but it is inside my form and there is more I want to do, like:

next to these five selections in the form will be a button for the user to choose that "plan" and when the user selects the "plan" they want I want the other plans to "hide".

Is this possible?

Here is what the layout resembles:

<form name="choose_plan" action="" method="post">
<table>
  <tr>
    <td>Plan 1</td><input type="image" src="choose_this_plan.gif" value="" name="">
  </tr>
  <tr>
    <td>Plan 2</td><input type="image" src="choose_this_plan.gif" value="" name="">
  </tr>
  <tr>
    <td>Plan 3</td><input type="image" src="choose_this_plan.gif" value="" name="">
  </tr>
  <tr>
    <td>Plan 4</td><input type="image" src="choose_this_plan.gif" value="" name="">
  </tr>
  <tr>
    <td>Plan 5</td><input type="image" src="choose_this_plan.gif" value="" name="">
  </tr>
</table>
</form>

<table>
 <tr>
   <td><img src="plan_image">This text and image to change CF event or otherwise</td>
 </tr>
</table>

0
Comment
Question by:lightning74
  • 2
6 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 125 total points
ID: 9757271
i beleive innerHTML is IE5+ only, also cf is a severside only to hide the options using cf youwould need to send the page back to the server, to do it client side you \will ned ascripting language, also if you hide the other options how can the user make a new selection if they change their mind?

in this instance i would suggest a dropdown box
<script>
      numPlans=5;
      function changeForm(strShow){
                   var strPlanId="";
                   for (var i=1;i<numPlans+1;i++){
                    strPlanId='Plan'+i;
                    document.getElementById(strPlanId).style.display='none';
                   }
        document.getElementById(strShow).style.display='block';
      </script>


<select id="selPlan" name="selPlan" style="width:250;" onChange="changeFormDisplay(this.value)">
<option value="">--Select a Plan Option</option>
<option value="plan1">Plan 1</option>
<option value="plan2">Plan 2</option>
<option value="plan3">Plan 3</option>
<option value="plan4">Plan 4</option>
<option value="plan5">Plan 5</option>
</select>

you can populate the options from a query using several methods, cfselect, cfoutput query, cfloop query.

<table id="tblOptionDisplay" name="tblOptionDisplay" border="1">
<caption><nobr>this is the div table</nobr></caption>
 <tr id="plan1" style="display:none">
   <td>Plan 1 info
   </td>
 </tr>
 <tr id="plan2" style="display:none">
   <td>Plan 2 info
   </td>
 </tr>
 <tr id="plan3" style="display:none">
   <td>Plan 3 info
   </td>
 </tr>
 <tr id="plan4" style="display:none">
   <td>Plan 4 info
   </td>
 </tr>
 <tr id="plan5" style="display:none">
   <td>Plan 5 info
   </td>
 </tr>
 
</table>
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9757283
made some corrections

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <title>Untitled</title>
      
      <script>
      numPlans=5;
      function changeFormDisplay(strShow){
                   var strPlanId="";
                   for (var i=1;i<numPlans+1;i++){
                    strPlanId='Plan'+i;
                    //hideId(strPlanId);
                    document.getElementById(strPlanId).style.display='none';
                   }
        if(strShow!=""){
                                  document.getElementById(strShow).style.display='block';
        }
      }
      
      function hideId(strId){
      
      document.getElementById(strId).style.display='none';
      }
      </script>
</head>

<body>

<form name="choose_plan" action="" method="post">
<select id="selPlan" name="selPlan" style="width:250;" onChange="changeFormDisplay(this.value)">
<option value="">--Select a Plan Option</option>
<option value="plan1">Plan 1</option>
<option value="plan2">Plan 2</option>
<option value="plan3">Plan 3</option>
<option value="plan4">Plan 4</option>
<option value="plan5">Plan 5</option>
</select>

</form>

<table id="tblOptionDisplay" name="tblOptionDisplay" border="1">
<caption><nobr>this is the div table</nobr></caption>
 <tr id="plan1" style="display:none">
   <td>Plan 1 info
   </td>
 </tr>
 <tr id="plan2" style="display:none">
   <td>Plan 2 info
   </td>
 </tr>
 <tr id="plan3" style="display:none">
   <td>Plan 3 info
   </td>
 </tr>
 <tr id="plan4" style="display:none">
   <td>Plan 4 info
   </td>
 </tr>
 <tr id="plan5" style="display:none">
   <td>Plan 5 info
   </td>
 </tr>
 
</table>

</body>
</html>
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9757801
Dont ever go for visible = true / false for form elements ... as it dosent work in netscape & other browsers

the best deal wld be to use layers & get them to be show / hide as per ur requirement

u wld be using javascript & DHTML !
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 9780984
You will have to use Javascript or some other client side scripting language since you want to access the onMouseover event.  The onMouseouver occurs on the client's machine and so therefore it cannot be done using only Cold Fusion which is a server side language.

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now