?
Solved

OnChange text Change

Posted on 2008-06-10
6
Medium Priority
?
1,131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…
Suggested Courses

764 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