Solved

OnChange text Change

Posted on 2008-06-10
6
1,121 Views
Last Modified: 2009-07-05
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

0
Comment
Question by:ronan_40060
  • 4
  • 2
6 Comments
 
LVL 22

Expert Comment

by:neeraj523
ID: 21749962
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
 
LVL 9

Author Comment

by:ronan_40060
ID: 21750416
Neeraj
yes Im  looking to change the name of a textbox on the change event of drop down

Thanks
0
 
LVL 22

Accepted Solution

by:
neeraj523 earned 125 total points
ID: 21750516
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Author Comment

by:ronan_40060
ID: 21758537
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
 
LVL 22

Expert Comment

by:neeraj523
ID: 21758641
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
 
LVL 22

Expert Comment

by:neeraj523
ID: 21792232
any further info needed ??
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 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

22 Experts available now in Live!

Get 1:1 Help Now