Solved

OnChange text Change

Posted on 2008-06-10
6
1,123 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript/JQuery - HtmlEncode (?) Ajax Result 1 67
jQuery Scroll To Top 5 39
Make Session back to empty 9 30
Alert after MVC form submitted 1 22
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

827 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