0

i am work on an app where combo box is define in each row of table in a jsp. when i select the specfic color from combo box it is doing the same color on whole row.
now i want, when i set the color of each row and submit the page using submit button when again i open the detail of the same id, previous state of colors can be show in a jsp which i have been set.

now situation is, after the submit when i again open the same id of a client, it show the color value on combo box which i have select but not show the associated color on a row.

this code making a combo box in .java file

public String getColor(String colorName) 
{
StringBuffer s1 = new StringBuffer();
s1.append("<select onchange=\"ChangeColor(this);\" style=\"font-size:0.8em;\" id=\"").append(colorName).append("\" name=\"").append(colorName).append("\">")
            .append("<option value=\"\">&nbsp;</option>");
}

function define in jsp page

function ChangeColor(colors) {
var partcolor = (colors.options[colors.selectedIndex].value);
if (partcolor=="black"){
  document.getElementById("colorRow").style.backgroundColor = 'black';
 } 
else if(partcolor=="brown")  {
 document.getElementById("colorRow").style.backgroundColor ='brown';
}   else if(partcolor=="yellow")  {
 document.getElementById("colorRow").style.backgroundColor ='yellow';
}
}

please help.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by javaAddict
0

When the page loads, if you have the color and you set it to the value of the select box then also set it at the row. Can you post the code where you set the selected option of the select box with the color, so we can get a better view on what you are doing.

Also don't use java to generate html tags like you do it at the method getColor. Everything about displaying and tags should go in the jsp.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.