473,803 Members | 4,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array null after split string

I'm a dummy. I have a basic knowledge of javascript and I want to split
a string, but I receive an error at line 15. Where my error in make the
array? Why? Can someone help me to resolve? Thank's.

The name of file is
E:\delibere test\pdf\2002\2 002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASC RIPT>
function verify(){
var estremi = new Array();
var entrata = new String;
var msg = new String;
entrata = document.fs.Fil e1.value
estremi = entrata.split["-"];
msg = "E\' corretto questo anno? \n" + estremi[0];
//all we have to do is return the return value of the confirm()
method
return confirm(msg);
}
</SCRIPT>

</HEAD>
<BODY>
<H1>File Upload</H1>

<H2>To File System</H2>
<FORM method="post" encType="multip art/form-data"
action="ToFileS ystem.asp" name="fs" onsubmit= "return verify()">
<INPUT type="File" name="File1">
<INPUT type="Submit" value="Upload">
</FORM>
</BODY>
</HTML>

Aug 31 '06 #1
3 6390
wrote on 31 aug 2006 in comp.lang.javas cript:
I'm a dummy. I have a basic knowledge of javascript and I want to split
a string, but I receive an error at line 15. Where my error in make the
array? Why? Can someone help me to resolve? Thank's.

The name of file is
E:\delibere test\pdf\2002\2 002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASC RIPT>
deprecated, use:

<script type='text/javascript'>
function verify(){
var estremi = new Array();
you do not need new Array(),
as it will be reassigned by split() anyway
var entrata = new String;
var msg = new String;
new String not needed, use:

var estremi,entrata , msg
entrata = document.fs.Fil e1.value
more complete and versatile:

entrata = document.forms['fs'].elements['File1'].value
estremi = entrata.split["-"];
This [] is your ERROR, use:

estremi = entrata.split("-");
msg = "E\' corretto questo anno? \n" + estremi[0];
Escaping the ' is not necessaty, do:

msg = "E' corretto questo anno?\n'" + estremi[0] + "'";
//all we have to do is return the return value of the confirm()
method
return confirm(msg);
}
</SCRIPT>

</HEAD>
<BODY>
<H1>File Upload</H1>

<H2>To File System</H2>
<FORM method="post" encType="multip art/form-data"
action="ToFileS ystem.asp" name="fs" onsubmit= "return verify()">
<INPUT type="File" name="File1">
<INPUT type="Submit" value="Upload">
</FORM>
</BODY>
</HTML>
Try:

<script type='text/javascript'>
function verify(theForm) {
var estremi,entrata , msg;
entrata = theForm.element s['File1'].value;
estremi = entrata.split('-');
msg = "E' corretto questo anno?\n'" + estremi[0] + "'";
return confirm(msg);
};
</script>

<FORM method='post' encType='multip art/form-data'
action='ToFileS ystem.asp' onsubmit= 'return verify(this);'>
<INPUT type='File' name='File1'>
<INPUT type='Submit' value='Upload'>
</FORM>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 31 '06 #2
ed***********@g mail.com wrote:
I'm a dummy. I have a basic knowledge of javascript and I want to
split a string, but I receive an error at line 15. Where my error in
make the array? Why? Can someone help me to resolve? Thank's.

The name of file is
E:\delibere test\pdf\2002\2 002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASC RIPT>
function verify(){
var estremi = new Array();
var entrata = new String;
var msg = new String;
entrata = document.fs.Fil e1.value
estremi = entrata.split["-"];
<snipped/>

estremi = entrata.split("-");

split is a function, thus you must use "(" and ")", not
square brackets "[" and "]".

--
Dag.

Aug 31 '06 #3
Thank you!
I used the name of the form and not "This". Mysterious javascript ;-)

Evertjan. ha scritto:
wrote on 31 aug 2006 in comp.lang.javas cript:
I'm a dummy. I have a basic knowledge of javascript and I want to split
a string, but I receive an error at line 15. Where my error in make the
array? Why? Can someone help me to resolve? Thank's.

The name of file is
E:\delibere test\pdf\2002\2 002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASC RIPT>

deprecated, use:

<script type='text/javascript'>
function verify(){
var estremi = new Array();

you do not need new Array(),
as it will be reassigned by split() anyway
var entrata = new String;
var msg = new String;

new String not needed, use:

var estremi,entrata , msg
entrata = document.fs.Fil e1.value

more complete and versatile:

entrata = document.forms['fs'].elements['File1'].value
estremi = entrata.split["-"];

This [] is your ERROR, use:

estremi = entrata.split("-");
msg = "E\' corretto questo anno? \n" + estremi[0];

Escaping the ' is not necessaty, do:

msg = "E' corretto questo anno?\n'" + estremi[0] + "'";
//all we have to do is return the return value of the confirm()
method
return confirm(msg);
}
</SCRIPT>

</HEAD>
<BODY>
<H1>File Upload</H1>

<H2>To File System</H2>
<FORM method="post" encType="multip art/form-data"
action="ToFileS ystem.asp" name="fs" onsubmit= "return verify()">
<INPUT type="File" name="File1">
<INPUT type="Submit" value="Upload">
</FORM>
</BODY>
</HTML>

Try:

<script type='text/javascript'>
function verify(theForm) {
var estremi,entrata , msg;
entrata = theForm.element s['File1'].value;
estremi = entrata.split('-');
msg = "E' corretto questo anno?\n'" + estremi[0] + "'";
return confirm(msg);
};
</script>

<FORM method='post' encType='multip art/form-data'
action='ToFileS ystem.asp' onsubmit= 'return verify(this);'>
<INPUT type='File' name='File1'>
<INPUT type='Submit' value='Upload'>
</FORM>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 31 '06 #4

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

Similar topics

11
39472
by: deko | last post by:
I need to create a basic one-dimensional array of strings, but I don't know how many strings I'm going to have until the code is finished looping. pseudo code: Dim astrMyArray() Do While Not rst.EOF i = i + 1 If rst!Something = Then astrMyArray(i) = rst!Something
4
8829
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where a * occurs in the string). This split function should allocate a 2D array of chars and put the split results in different rows. The listing below shows how I started to work on this. To keep the program simple and help focus the program the...
9
2263
by: Arjen | last post by:
Hello, Persons is a hashtable which I convert to an array. Person aPerson = new Person; Persons.Values.CopyTo( aPerson, 0 ); Now I can access the person items like aPerson.name or aPerson.birthdate.
1
21883
by: davehunt | last post by:
Hi folks, New C# programmer here. I am reading some CSV data from a file into an ArrayList. I want to get the data from the ArrayList into a 2-dimensional array. I see a few references to ..Split, but I'm not sure that's what I need. So, basically, what I have loaded into the ArrayList is:
4
15007
by: John | last post by:
Hi I need to return an array of string in my own split function (access 97). I have defined the function as below but I get err on 'As String()'. What can I do to make the function return an array of strings? Public Function Split(ByVal strIn As String, Optional strDelimiter As String = " ") As String() Thanks
7
9549
by: Paul M. Cook | last post by:
Let's say you have a CSV file and you load it into a variant array using the split function on VBCrLF. Then you load a variable with the line count and loop through the array for 0 to line count. This works well unless you have blank lines at the end of the CSV file. Now if you process the loop, you'll get an out of bounds subscript at the end of the loop because you are referencing null values at the end of the variant array. How...
18
3642
by: Kyro | last post by:
New to C# (migrating from Delphi) and I'm not sure how to get a delimited string into an array of string. input: string looks like - 01-85-78-15-Q11 output: an array with elements - 01,85,78,15 etc... Is there some sort of easy one liner that does this? Hard to search the help files for anything that would assist me in doing this. Thanks in advance.
10
5914
by: vignesh4u | last post by:
I am trying to implement the Split function in C ie. if i have a string: char* S="This is a test"; and if i try to split based on space ' ' it should return an array of strings like: {"This","is","a","test"} . I tried to implement it as given below but am getting a segmentation fault. I would really appreciate if some one could give me an answer on this issue:
6
5185
by: Studlyami | last post by:
Okay, i have developed a file parser in C++ that i am trying to being into a c# program which is proving to be a lot more difficult than i thought. first i scan a file (which i opened using a streamreader) until i find a keyword that i specified. Then i want to grab the items after that keyword and do a switch on them. In C++ it looked something like this char* FileToken; char LineBuffer; while (Test != NULL) //i haven't reach eof....
4
3333
by: setiarakesh | last post by:
I have designed a socket Server and developed asynchronous server . It is working fine with 60 Clients which are connecting to ths Server running at Machine (2 GB RAM and OS is Windows 2003 Server)having IP which is Mapped with static IP and Port in firewall . The Programme is working fine with 60 clients and rate if incoing data on the server is 5 -6 string of 1024 byte size are being saved in DataBase. When i try to connect ...
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
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
10069
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
9125
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
7604
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
6842
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
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.