473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Browser Field

Cy
I have a form that contains several browse fields for users to upload files.
There is also a hidden field that is populated using javascript.

This script reads the value of the browse field, splits the string and
returns the name of the file to the hidden field. This is done so the file
name can be re-used.

My problem is that the javascript appears to be unable to read the browse
field in order to send the file name to the hidden field. This works
perfectly in IE, but Mozilla, Netscape and Firebird is a different story.

Is there a problem with my code, or is this a browser problem? If it is a
code problem, do you have any suggestions?

Here is the code and how it works:

function get_image_name(browse_field, hidden_field) { //file_name
var local_image = document.getElementById(browse_field).value;
var file_path_array = local_image.split("\\");
document.getElementById(hidden_field).value =
file_path_array[file_path_array.length-1];
}

Each browser and hidden form field have the same name, except for a number.
The values passed tot he function could be read as ('image_2',
'image_name_2')
1) browse_field - An onChange event triggers this function and the value of
the browse_field is stored in the variable local image.

2) The value of local_image is then split to create an array of the
directories and file name. I only need the file name.

3) The value of the last element in the array (the file name) is then passed
to the hidden field

Thanks for any and all help I can get.
Cy
Jul 20 '05 #1
1 1918
> This script reads the value of the browse field, splits the string and
returns the name of the file to the hidden field. This is done so the file
name can be re-used.

My problem is that the javascript appears to be unable to read the browse
field in order to send the file name to the hidden field. This works
perfectly in IE, but Mozilla, Netscape and Firebird is a different story.

Is there a problem with my code, or is this a browser problem? If it is a
code problem, do you have any suggestions?

Here is the code and how it works:

function get_image_name(browse_field, hidden_field) { file://file_name
What's with the file:???
var local_image = document.getElementById(browse_field).value;
var file_path_array = local_image.split("\\");
I would be very suspicious of the above line as you don't know how the
browser is reading the file path.

Why don't you put in some alerts so you can trace the variables?

alert(local_image);
alert(file_path_array[file_path_array.length-1);

Jeff.

document.getElementById(hidden_field).value =
file_path_array[file_path_array.length-1];
}

Each browser and hidden form field have the same name, except for a number. The values passed tot he function could be read as ('image_2',
'image_name_2')
1) browse_field - An onChange event triggers this function and the value of the browse_field is stored in the variable local image.

2) The value of local_image is then split to create an array of the
directories and file name. I only need the file name.

3) The value of the last element in the array (the file name) is then passed to the hidden field

Thanks for any and all help I can get.
Cy

Jul 20 '05 #2

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

Similar topics

7
7068
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
1
2746
by: Boris Wilhelms | last post by:
Hello all, at first, sorry for my bad English, I’ll give my best  We have a strange problem reading Text- and VarChar-Fields. Our configuration: -Windows 2003 Server -MySQL Server 3.23.36...
1
5996
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that...
5
1959
by: Abyss | last post by:
My view. anyone that doesn't like it tough, click off and stop reading it. I have spent the last 45 minutes reading through all the posts, and I believe that you have all missed the mark of...
7
2757
by: jamait | last post by:
Hi all, I m trying to read in a text file into a datatable... Not sure on how to split up the information though, regex or substrings...? sample: Col1 Col2 ...
0
1605
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id of the picture (an integer) and one (column named picture) is a field of type OLE Object which...
29
2981
by: Jerim79 | last post by:
I did try to find the answer to this before posting, so this isn't a knee jerk reaction. What I am trying to accomplish is to have a script that opens a cookie, reads a value, and then use a...
0
2174
by: Anish G | last post by:
Hi, I have an issue with reading CSV files. I am to reading CSV file and putting it in a Datatable in C#. I am using a regular expression to read the values. Below is the code. Now, it reads...
21
3015
by: Stephen.Schoenberger | last post by:
Hello, My C is a bit rusty (.NET programmer normally but need to do this in C) and I need to read in a text file that is setup as a table. The general form of the file is 00000000 USNIST00Z...
0
7201
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
7083
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...
0
7328
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...
1
6988
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...
0
7456
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...
0
4672
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
1510
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 ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
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.