Jump to content

updating div w/ onClick()


Recommended Posts

Basic concept: table of product info:

<table style="background-color:#000000" class="result">    <tr> 	 <td ><strong>Item Number</strong></td> 	 <td><strong>Plant Type</strong></td> 	 <td><strong>Plant Name</strong></td> 	 <td style="text-align:center"><strong>Plant Cost</strong></td> 	 <td style="text-align:right"><strong>Flower Color</strong></td>    </tr>    <cfoutput query="#Search_Yes#">    <tr onmouseover='this.bgColor="darkblue"' onmouseout='this.bgColor="black"'>   	 <td height="10px">#Item_Number#</td> 	 <td height="10px">#Plant_Type#</td> 	 <td height="10px">#Plant_Name#</td> 	 <td height="10px" style="text-align:center">#Plant_Cost#</td> 	 <td height="10px" style="text-align:right">#Flower_Color#</td>    </tr>    </cfoutput>   </table>

So, as you place your cursor over each entry in the list, the entire entry is highlighted. I have a div out to the side that floats, and eventually want it to update to the selected product when you click on the product table row. My thought was adding an onClick="Set_Product_Var()" with the rest of the second table row tag. Then, Set_Product_Var() would set some variables(ie plant name, picture src, description, etc) according to the selected row. Then, the div would update itself. Is this flawed, I attemted a simple implementation of this idea, putting one variable in the function, and a div trying to recall that variable and merely display it. It failed. Thanks for any help on this topic.

Link to comment
Share on other sites

It would help if you gave more details about your onClick method. Try posting the code you were using for that method.In any case, what i would have done would be define the onclick function like this:Giving the DIV an id of "info", the function would be: -

function Set_Product_Var(id){var info = document.getElementById('info')var details = new Array()details[0] = "Product A. Price $3.00"details[1] = "Product B. Price $2.50"details[2] = "Product C. Absoultely Free!"info.innerHTML = details[id]}

Basically make an array with information for each product id.And each time you do the onclick function, put the argument as the row # or product id or whatever.Like onclick="Set_Product_Var(2)"etc.Of course, you might have something else in mind... therefore just post what you were trying to do.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...