Solved

OnChange text Change

Posted on 2008-06-10
6
1,120 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
JDeveloper 12c for 32 bit 4 35
Auto Submit on dropdown box 3 36
Javascript in a user control not working 17 53
Problem to page 4 26
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'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

762 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

19 Experts available now in Live!

Get 1:1 Help Now