473,480 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Create 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\2002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASCRIPT>
function verify(){
var estremi = new Array();
var entrata = new String;
var msg = new String;
entrata = document.fs.File1.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="multipart/form-data"
action="ToFileSystem.asp" name="fs" onsubmit= "return verify()">
<INPUT type="File" name="File1">
<INPUT type="Submit" value="Upload">
</FORM>
</BODY>
</HTML>

Aug 31 '06 #1
3 6369
wrote on 31 aug 2006 in comp.lang.javascript:
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\2002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASCRIPT>
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.File1.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="multipart/form-data"
action="ToFileSystem.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.elements['File1'].value;
estremi = entrata.split('-');
msg = "E' corretto questo anno?\n'" + estremi[0] + "'";
return confirm(msg);
};
</script>

<FORM method='post' encType='multipart/form-data'
action='ToFileSystem.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***********@gmail.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\2002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASCRIPT>
function verify(){
var estremi = new Array();
var entrata = new String;
var msg = new String;
entrata = document.fs.File1.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.javascript:
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\2002-01-01-GC-000-Testo.pdf

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JAVASCRIPT>

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.File1.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="multipart/form-data"
action="ToFileSystem.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.elements['File1'].value;
estremi = entrata.split('-');
msg = "E' corretto questo anno?\n'" + estremi[0] + "'";
return confirm(msg);
};
</script>

<FORM method='post' encType='multipart/form-data'
action='ToFileSystem.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
39423
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...
4
8768
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...
9
2245
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...
1
21822
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...
4
14985
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...
7
9524
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. ...
18
3598
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 - ...
10
5878
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: ...
6
5168
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...
4
3315
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...
0
7046
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7048
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,...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4783
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...
0
4485
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...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2986
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
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 ...
0
183
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...

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.