473,800 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to separate this string

Hi forum, i'm a little new in javascript and maybe you can help me.

I have an html form and an icon, if i click on the icon, a new pop-up
window is open and shows a list of numbers with a structure like this
:
x.xx.xxx.xxxx.

Now, this numbers are between an <a href> tag and if i clic on one of
this, i call a javascript function, the idea is to put each one number
separate for the "." in a textbox, so i did it before but putting it
in a single input. Now i need to separate each one of this numbers and
put it in each one of the textbox. If i have to put it in a single
input i´ll do something like this:

<script language="javas cript">
function Funcion(val)
{
//val value is 1.12.123.1234
window.parent.o pener.document. txtCtaNiv.value =val;
top.parent.wind ow.close();
}
</script>

The code above puts the value (that previosuly i selected in the popup
window) in the input field of the main form. That's easy.

Now if the parameter val has the value 1.12.123.1234 and in the main
form i have four input fields called txtCtaNiv1, txtCtaNiv2,
txtCtaNiv3, txtCtaNiv4, how can i separate the parameter val?, so i
can put the 1 in txtCtaNiv1, the 12 in the input field txtCtaNiv2, the
123 in txtCtaNiv3 and so on??

Please if someone can give some example or idea will be great

Thanls in advanced.
Jul 20 '05 #1
3 1882
LJL
ro****@disicom. com (Roberto Becerril) wrote in
news:ae******** *************** **@posting.goog le.com:
Hi forum, i'm a little new in javascript and maybe you can help me.

I have an html form and an icon, if i click on the icon, a new pop-up
window is open and shows a list of numbers with a structure like this
:
x.xx.xxx.xxxx.

Now, this numbers are between an <a href> tag and if i clic on one of
this, i call a javascript function, the idea is to put each one number
separate for the "." in a textbox, so i did it before but putting it
in a single input. Now i need to separate each one of this numbers and
put it in each one of the textbox. If i have to put it in a single
input i´ll do something like this:

<script language="javas cript">
function Funcion(val)
{
//val value is 1.12.123.1234
window.parent.o pener.document. txtCtaNiv.value =val;
top.parent.wind ow.close();
}
</script>

The code above puts the value (that previosuly i selected in the popup
window) in the input field of the main form. That's easy.

Now if the parameter val has the value 1.12.123.1234 and in the main
form i have four input fields called txtCtaNiv1, txtCtaNiv2,
txtCtaNiv3, txtCtaNiv4, how can i separate the parameter val?, so i
can put the 1 in txtCtaNiv1, the 12 in the input field txtCtaNiv2, the
123 in txtCtaNiv3 and so on??

Please if someone can give some example or idea will be great

Thanls in advanced.


var dummy = val.split('.');
document.getEle mentById('txtCt aNiv1').value = dummy[0];
document.getEle mentById('txtCt aNiv2').value = dummy[1];
document.getEle mentById('txtCt aNiv3').value = dummy[2];
document.getEle mentById('txtCt aNiv4').value = dummy[3];

The "split" method breaks up a string based upon a character in that
string. In this case, the period between the numbers. It then puts those
parts of the original string into an array, in this case "dummy".

You may need to modify the "document.getEl ementById" sections to use the
form name and elements names, but it should be something similar.

Good luck, LJL
Jul 20 '05 #2
JRS: In article <ae************ *************@p osting.google.c om>, seen
in news:comp.lang. javascript, Roberto Becerril <ro****@disicom .com>
posted at Sun, 1 Feb 2004 22:48:15 :-
Now if the parameter val has the value 1.12.123.1234 and in the main
form i have four input fields called txtCtaNiv1, txtCtaNiv2,
txtCtaNiv3, txtCtaNiv4, how can i separate the parameter val?, so i
can put the 1 in txtCtaNiv1, the 12 in the input field txtCtaNiv2, the
123 in txtCtaNiv3 and so on??

The following, executed in <URL:http://www.merlyn.demon.co.uk/js-
quick.htm> with the Eval button, puts the four substrings in the F.Xn
controls.

S = "1.12.123.1 234"
T = S.split('.')
for (J=0 ; J<4 ; J++) F.elements["X"+J].value = T[J]

You should be able to adapt it.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #3
Thanks a lot for the help, it was just what i needed!!
LJL <no**@nowhere.c om> wrote in message news:<Xn******* *************** ******@207.69.1 54.205>...
ro****@disicom. com (Roberto Becerril) wrote in
news:ae******** *************** **@posting.goog le.com:
Hi forum, i'm a little new in javascript and maybe you can help me.

I have an html form and an icon, if i click on the icon, a new pop-up
window is open and shows a list of numbers with a structure like this
:
x.xx.xxx.xxxx.

Now, this numbers are between an <a href> tag and if i clic on one of
this, i call a javascript function, the idea is to put each one number
separate for the "." in a textbox, so i did it before but putting it
in a single input. Now i need to separate each one of this numbers and
put it in each one of the textbox. If i have to put it in a single
input i´ll do something like this:

<script language="javas cript">
function Funcion(val)
{
//val value is 1.12.123.1234
window.parent.o pener.document. txtCtaNiv.value =val;
top.parent.wind ow.close();
}
</script>

The code above puts the value (that previosuly i selected in the popup
window) in the input field of the main form. That's easy.

Now if the parameter val has the value 1.12.123.1234 and in the main
form i have four input fields called txtCtaNiv1, txtCtaNiv2,
txtCtaNiv3, txtCtaNiv4, how can i separate the parameter val?, so i
can put the 1 in txtCtaNiv1, the 12 in the input field txtCtaNiv2, the
123 in txtCtaNiv3 and so on??

Please if someone can give some example or idea will be great

Thanls in advanced.


var dummy = val.split('.');
document.getEle mentById('txtCt aNiv1').value = dummy[0];
document.getEle mentById('txtCt aNiv2').value = dummy[1];
document.getEle mentById('txtCt aNiv3').value = dummy[2];
document.getEle mentById('txtCt aNiv4').value = dummy[3];

The "split" method breaks up a string based upon a character in that
string. In this case, the period between the numbers. It then puts those
parts of the original string into an array, in this case "dummy".

You may need to modify the "document.getEl ementById" sections to use the
form name and elements names, but it should be something similar.

Good luck, LJL

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2638
by: Jaime Wyant | last post by:
I know I've seen this somewhere, but can't seem to google it. Is there a way to use an alternate statement separator, other than the default ';'? jw
2
1797
by: Stian | last post by:
Hi! I have made a form with two SELECT LIST-boxes where the first is dynmically filled when you enter the page, and then one can select multiple options from the list and move across to the other box using javascript. Every option in the list has an integer value. The FORM is submitted with the POST method and received on an ASP page. I then want to manage the selected options one by one. How can I separate them?
3
10571
by: harhaiko | last post by:
Hello, I have 4,4 million rows of data in one column. I want to search for a string in each line. There are random amount of characters before the string I want to find. The string starts with the letter "V" and I also know that after the letter V comes seven digits or letters which I want to find also. After that string there are random amount of characters. What kind of query I should create to find all those strings within my data? I...
2
34569
by: ad | last post by:
I have a string vaiable like "1a3345"; How to separate the string into a char array or a string array just have on character per element?
28
4379
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I added a class to project and it's named XmlApi(). In the XmlAPI() class I have simple code as following XmlAPI() { string str = "Some Text";
12
2795
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
1
1238
by: drec | last post by:
I have a very simple mysql/php script that is being used to store program keys in a db for multiple users. I would like to add the ability to send these string values to another application. In doing some research it looks like the VB function SendKeys is what I would like to be able to do using PHP. Simply copy and pasting these values will not work, because the string is 20 + characters long, and the applications where these strings...
2
2323
by: colleen1980 | last post by:
Hi: Can any one please tell me how do i separate city state and zip. I ask this question in previous post. But when the city name is in two words it mess up my values otherwise it works. CityStateZip ------------- Las Vegas NA, 12345 Oradell NJ, 07649 Bay Shore NY, 11703
14
1981
by: Lambda | last post by:
I'd like to create separate character pointers, pass them to a function to assign each one different value, and assign the pointers to an array. But when I try: #include <stdio.h> #include <string.h> int main(void)
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.