Javascript problem
by "Rajnish Bhaskar" <r.bhaskar(at)compserv.gla.ac.uk>
|
| Date: |
Tue, 2 Oct 2001 12:26:05 +0100 |
| To: |
hwg-languages(at)hwg.org |
| |
todo: View
Thread,
Original
|
|
Hi folks,
I've got a small Javascript function that should parse form elements
and remove a certain string from it. This seems to work fine in
NN4.7 and IE5.5 but not in Mozilla 0.9.4 which uses the W3C
DOM. I'm not familiar with this DOM and was wondering if anybody
can see what I'm doing wrong here (or is it a Mozilla bug?):
//removes all of the field indicators from the field names
// "input" is a form
function cleanNames(input)
{
// returns a string, currently "req_"
var requiredField= getRequiredField();
for (count= 0; count<input.length; count++)
{
currentField= input.elements[count].name;
if (currentField.indexOf(requiredField) != -1)
{
var tempString= currentField.substring(0,
currentField.indexOf(requiredField));
tempString +=
currentField.substring((currentField.indexOf(requiredField)+
requiredField.length), currentField.length);
input.elements[count].name= tempString;
} // end if
} // end loop
} // end function cleanNames()
Eg, if I had fields req_surname and req_forename, it should strip
out the "req_" and just return "surname" and "forename", but when
I add an alert so that I can see the new elements as they're being
added, anything that had "req_" is now coming up blank.
Thanks,
Raj.
--
Rajnish Bhaskar
r.bhaskar(at)compserv.gla.ac.uk, http://lordofthemoon.com
IT Education Unit, University of Glasgow
http://www.iteu.gla.ac.uk/
--
Thought for the day:
Dictatorship (n): a form of government under which everything
which is not prohibited is compulsory.
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.