Javascript change HTML button value not working in iE7

I have to change the value of a button i.e. the button text.

I have to be able to click on a button on a row in the table and then fill  in the form and then clcik again and its disabled like before.

Problem is now that you click the edit button and it changes to save - you cannot change it back though. Cannot use two buttons as this makes more JS code (much more).

This is the HTML for it:

<?
                  while($company_contacts_row = mysql_fetch_array($company_contacts_query))
                  {      
                        echo "<tr>";      
                        echo "<td>";      
                        echo "<input type='text' name='type".$company_contacts_row['contact_id']."' id='type".$company_contacts_row['contact_id']."' value='".$company_contacts_row['type']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";  
                        echo "</td>";
                        
                        echo "<td>";
                        echo "<input type='text' name='name".$company_contacts_row['contact_id']."' id='name".$company_contacts_row['contact_id']."' value='".$company_contacts_row['title']." ".$company_contacts_row['fname']." ".$company_contacts_row['lname']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";  
                        echo "</td>";
                        
                        echo "<td>";
                        echo "<input type='text' name='mobile".$company_contacts_row['contact_id']."' id='mobile".$company_contacts_row['contact_id']."' value='".$company_contacts_row['mobile']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";  
                        echo "</td>";
                                                
                        echo "<td>";
                        echo "<input type='text' name='main_contact".$company_contacts_row['contact_id']."' id='main_contact".$company_contacts_row['contact_id']."' value='".$company_contacts_row['main_contact']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";  
                        echo "</td>";
      
                        echo "<td>";
                        echo "<input type='text' name='email".$company_contacts_row['contact_id']."' id='email".$company_contacts_row['contact_id']."' value='".$company_contacts_row['email']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";                          
                        echo "</td>";
                        
                        echo "<td>";
                        echo "<input type='text' name='responsible_for".$company_contacts_row['contact_id']."' id='responsible_for".$company_contacts_row['contact_id']."' value='".$company_contacts_row['responsible_for']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";  
                        echo "</td>";

                        echo "<td>";
                        echo "<input type='text' name='".$company_contacts_row['contact_id']."' id='".$company_contacts_row['contact_id']."' value='".$company_contacts_row['main_telephone']."' disabled style='background-color:#97baef;width:60px;border:1px solid #97baef;' onchange='makeLocked(this.id)'>";                          
                        echo "</td>";
                        
                        echo "<td width='25px'>";
                        echo "<input type='button' value='Edit' id='edit_button".$company_contacts_row['contact_id']."' name='edit_button".$company_contacts_row['contact_id']."' onClick='makeEditable(".$company_contacts_row['contact_id'].");'>";
                        echo "</td>";
                        
                        echo "<td width='30px'>";
                        echo "<input type='button' value='Remove' onClick='remove_contact(".$company_contacts_row['contact_id'].",".$company_id.");'>";                        
                        echo "</td>";                              
                        echo "</tr>";
                  }      
            }                  
            ?>

Also the second problem is that the fields when disabled have the wrong text colour - black would be better, is there a hack or alternative method for this.

Would really appreciated some help with this one.
Thanks
function makeEditable(whichOne)
{	
	if(document.getElementById(whichOne).disabled == true)
	{
		document.getElementById('name' + whichOne).disabled = false;
		document.getElementById('name' + whichOne).style.backgroundColor = "#ffffff";
		document.getElementById('type' + whichOne).disabled = false;
		document.getElementById('type' + whichOne).style.backgroundColor = "#ffffff";
 
		var name = document.getElementById('name' + whichOne).value;
		var type = document.getElementById('type' + whichOne).value;
 
		document.getElementById('edit_button' + whichOne).value = "Save";
		
		get_ajax();
 
		xmlHttp = new XMLHttpRequest();
		xmlHttp.open("GET", "secured/save_contact_row.php?contact_id=" + whichOne + "&name=" + name  + "&type=" + type + "&mobile=" + mobile + "&responsible_for=" + responsible_for + "&main_contact=" + main_contact + "&email=" + email, false);
		xmlHttp.send(null);	
		xmlDoc = xmlHttp.responseText;
		
		if(xmlDoc == 'redirect_index_open_add')
		{
			//alert("test1");
			window.location = 'index.php?cmd=editContact&pg=3&company_id=' + company_id + '';
		}
	}
	else if(document.getElementById(whichOne).disabled == false)
	{
		document.getElementById('name' + whichOne).disabled = true;
		document.getElementById('name' + whichOne).style.backgroundColor = "#97baef";
		document.getElementById('type' + whichOne).disabled = true;
		document.getElementById('type' + whichOne).style.backgroundColor = "#97baef";
 
		document.getElementById('edit_button' + whichOne).childNodes[0].nodeValue = "Edit";
	}
}
 
function makeLocked(whichOne)
{
    document.getElementById('name' + whichOne).disabled = true;
    document.getElementById('name' + whichOne).style.backgroundColor = "#97baef";
	document.getElementById('type' + whichOne).disabled = true;
    document.getElementById('type' + whichOne).style.backgroundColor = "#97baef";
 
	document.getElementById('edit_button' + whichOne).childNodes[0].nodeValue = "Edit";
}

Open in new window

ravinesolutionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ravinesolutionsAuthor Commented:
By the way the JS code has been shortened and anow only applies for 2 of the input fields for the sake of the example.
0
ravinesolutionsAuthor Commented:
This question no longer needs answering - I am changing the method inwhich I construct this form.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.