[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

One field to equal onther with expection

Posted on 2009-04-11
4
Medium Priority
?
281 Views
Last Modified: 2012-05-06
I have a field called Buyer_Name I also have a field called Buyer_1 and Buyer_2
I need a java code that when a person types the info to Buyer_Name and PLaces "&" in the text it divides the info into 2 fields for example.

Buyer_Name = Jose Castro & Joana Castro
Buyer_1 = Jose Castro
Buyer_2 = Joana Castro

I am new to this and would like a hand can someone post a working example.
0
Comment
Question by:eteran
[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
  • 2
4 Comments
 

Author Comment

by:eteran
ID: 24124277
I have done some research understand the logic but need help putting it together.

I am assuming this will be a left and right split
Buyer_Name = Jose Castro & Joana Castro
So for buyer it would be a left split till "&" sign for Buyer_1 and for Buyer_2 it would be a left split till the "&" sign. How can I set this up.  
0
 
LVL 9

Accepted Solution

by:
Mahdii7 earned 2000 total points
ID: 24124320
Let me know if this needs further explanation...
<script>
function split_names(id){
	var el = document.getElementById(id);
	var out = document.getElementById('output');
	var string = el.value;
	var done = string.split("&");
	var out_str = "We split this into the following: <br/>";
 
	for (i=0; i<done.length; i++){
		out_str += (i+1) + " : " + done[i] + "<br />";
	}
	out.innerHTML = out_str;
}
</script>
<div style="width:100%;" align="center"><input id="for_testing" /><input type="button" value="Split!" onclick="split_names('for_testing');" /></div>
<div style="width:100%;" align="center" id="output"></div>

Open in new window

0
 

Author Comment

by:eteran
ID: 24124336
How do I call info from a field in java??

Field textbox name is Buyer_Name

I want to transfer the info when the mouse or curser get off the text fileld.
I would like to have the code check if the Html field exists called Buyer_1 if so then do the Split and input the rest of the info after & that split.

I am sorry just never coded on java and just trying things. Please help so I can learn it well.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24174225
Where is your code?  Show us how you are using what the expert provided.  In the example the expert gave you the function is called by pressing the Split! button.  You could use an onblur event in the input box for Buyer Name but will the user input that info and what is the html for the inputs?  If you need specifics please show us the html and how you have the script above in your code.  I will be glad to show you how to use it.
bol
p.s.  Please use Javascript or maybe JS instead of Java.  Java is a completely different language and not used in browsers for clientside scripting.  Using that name will just cause confusion.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

649 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