Solved

OnChange text Change

Posted on 2008-06-10
6
1,122 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

772 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