OnChange text Change

Hello Experts

Im writing a Small javaScript function that will change text Box name on change of Yes/No of Drop Down box Multiple Recipients
E.G
If Multiple Recipients Drop Down has  Yes then the text Box name below should have the name displayed Group Address else If No is selected then the text filed below has the nameCust Email Address.

I have attached the code snippete of what I have written so far  
 
Thanks in advanced
function function1(text) {
        var col = (text.options[text.selectedIndex].value);
        if (col) { 
           document.write('Cust Email Address'); 
        }
        alert("The Text has changed to "+col) 
    }

Open in new window

LVL 9
ronan_40060Asked:
Who is Participating?
 
neeraj523Connect With a Mentor Commented:
Attached is a small sample code which may show you right direction..
<form name="myform">
	<select id="combo" onChange=function1(this)>
		<option value="true">True</option>
		<option value="false">False</option>
	</select>
   <input type="text" name="txt" id="txtBox" size="40">
</form>
 
<SCRIPT>
document.getElementById("txtBox").value = "My name is currently '" + document.getElementById("txtBox").name + "'"; 
function function1(text) 
{
        var col = (text.options[text.selectedIndex].value);
		alert(col)
        if (col == "true") 
		{ 
           document.getElementById("txtBox").name = "txtTrue"; 
           document.getElementById("txtBox").value = "My name is now 'txtTrue'"; 
		}
		else
		{
           document.getElementById("txtBox").name = "txtFalse"; 
           document.getElementById("txtBox").value = "My name is now 'txtFalse'"; 
		}
}
</SCRIPT>

Open in new window

0
 
neeraj523Commented:
Hello

Your question is not very clear. Can you elaborate it a bit..

Are you looking to change the name of a textbox on the change event of drop down ?

neeraj523
0
 
ronan_40060Author Commented:
Neeraj
yes Im  looking to change the name of a textbox on the change event of drop down

Thanks
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ronan_40060Author Commented:
This is How my code looks like
function textChange(text)
{
        alert("inside Text Change Function");
        var col = (text.options[text.selectedIndex].value);
            alert(col)
        if (col == "true")
            {
           document.getElementById("custEmailAddress").name = "Group's Name:";
           document.getElementById("custEmailAddress").value = "'Group's Name:'";
            }
            else
            {
           document.getElementById("custEmailAddress").name = "Cust Email Address";
           document.getElementById("custEmailAddress").value = "Cust Email Address";
            }
}
Now when I call this function from JAVA FE with Drop down value changed to YES , Cust Email Address values gets populated in the text filed instead of changing the TextBox name
custEmailAddress is the id that Im using
0
 
neeraj523Commented:
I dont understand why you want to change the name of textbox on some event..

anyway.. value of the text box is changing because of
          document.getElementById("custEmailAddress").value = "'Group's Name:'";
       document.getElementById("custEmailAddress").value = "Cust Email Address";

lines.. i added these lines to show you how the things r changing.. if u delete these two lines.. value wont be changed..

0
 
neeraj523Commented:
any further info needed ??
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.