trojan_uk
12-15-2003, 12:14 PM
Hi,
Save posting all the code I will try to explain first, I have a drop down menu that is built from a database and contains peoples names, at he same time I have also built an array in vbscript that contains the numbers and names and convert this into a JS array and this is used in a find funtion. each name has an id number associated with it, the idea is that when somebody selects a name from the dropdown list the number appears in a field below, now I have used this code in several pages and everything works fine.
However I am using it with different data and get an error saying 'object expected' I looked through the array and everything looked fine except part of one of the surnames was in Parenthesis (Blair)MacIntyre, so I put a condition on the selet option to make sure that this name was not returned and when I tried it again it worked.
My question is will having the name set out this way cause the error and if so how can I get around it without amending the name:
This is the script and array as it appears in the page I have marked the name in red that I suspect is causing the problem:
<script type="text/javascript">
var SECT = ['Mary-Grace Anderson','113784','Zeffrey Lucas','115521','Andy Dodd','118007','Graham Robinson','124423','Dave Martin','132261','Dirk Smit','134706','Darryl Wilkinson','134783','Dick Wynberg','134783','Gareth Pleavin','136629','Peter Slaiby','144210','Peter Jackson','144210','Anthony Charnley','144210','Chris Rowsell','146302','Malcolm Parker','146478','Eric Waugh','146478','Paul Newman','148305','Brian Humphries','149576','Dave Casson','149581','Eric Clark','149581','Tony Cramp','149581','Cliff Edwards','149581','Brian Teeder','149581','Vince Rylance','149581','Bob Sheffield','149581','Jonathan Phillips','149586','Ray Reynolds','149586','Steve Walters','149586','Jonathan Cavanagh','149586','Jon Mason','152583','Robbie McFegan','153068','Mike Hopprich','153333','Jim Beresford-Lambert','157117','Luuk Karsten','157267','Paul Carter','158232','Tom Botts','158524','Kieron McFadyen','158524','Mark Haselden','160336','Mark Haselden','160336','Paul Snaith','161191','Cliff Dorman','161279','Mick McMahon','162665','Bob Oorschot van','165987','Andrew Kerr','167587','Peter Allen','167587','David Martin','169488','Sue Paterson','171500','Nicola Gordon','171521','David Bostock','173444','Didrik Reymert','173576','Karen Leadbitter','173766','Kevin Wright','173804','Roger Patey','173897','Greg Hill','173899','Engelhardt Robbe','173900','Mike Conway','173901','Tom Hyde','175340','Ruth Leach','176937','Ruth Leach','176937','Simon Barnard','177002','Stuart Tester','177315','Toba Akinmoladun','178601','Ian Bradshaw','178954','Jim De Haseth','180543','Jim De Haseth','180543','Graham Smith','180543','Steve Starkey-Jones','181465','Stephen Whyte','181997','Line Sorensen','71986A','Andrew Cates','71986A','James Nyhan','71986A','Andrew Moretti','71986A','William Taylor','75047','Ken Rivers','80529','Paul Zealand','83740','Dick Leitch','84311','Colin Main','87638','John Harmer','87638','Adrian Loader','SCE000050','David Beer','SCE000335','John Wills','SCE000335','Michiel Moolenaar','SCE000350','Santurnino De Andres','SCE000358','David Young','SCE000358','Andrew Robson','SCE000405','Chris Worsley','SCE000466','Pat O'Driscoll','SCE000585','Ben Van Beurden','SCE000607','David Lawrence','SCE000608','Chris.R Ellins','SCE000608','Mike Napier','SCE000613','Bill Colquhoun','SCE000783','Simon Smith','SCE000792','Ronald Blakely','SCE000898','Lisa Davis','SCE000898','Hans Vlemmings','SCE000923','Neil.R Gaskell','SCE000966','Xavier Le Mintier','SCE001002','Joris Kniep','SCE001102','Wouter De Vries','SCE001102','Giles Craven','SCE001258','Mary Jo Jacobi','SCE001284','Susan Lamb','SCE001312','Nicola Lancaster','SCE001312','Mike Green','SCE001312','Michiel Mak','SCE001370','Julienne Baron','SCE001493','Robert Craig','SCE001507','. Modem','SCE001592','Phil.B Watts','SCE001592','Beat Hess','SCE001905','Albert Bressland','SCE002002','Renger Bierema','SCE002160','Andrew Blazye','SCE002171','Leslie Van De Walle','SCE002264','Martin Foley','SCE002267','Stan Bradbury','SCE002268','Steve Harman','SCE002270','Graeme Sweeney','SCE002457','Mike Wilkinson','SCE002811','Paul.D Skinner','SCE002813','Rob Routs','SCE002813','Rachel English','SCE002990','Guy Outen','SCE002990','Andrew Manley','SCE003068','Jyoti Munsiff','SCE003207','Richard Mann','SCE003213','Michael O'Callaghan','SCE003307','Cornelia Mckendrick','SCE003317','Justine Berkovitz','SCE003317','Keith Ruddock','SCE003317','Gillian Thorn','SCE003317','Ronald Schellekens','SCE003383','Abby Street','SCE003427','Bob Fryer','SCE003516','Ken Dean','SCE003526','Trevor Hobson','SCE003559','Nic Turner','SCE003837','John.D Hofmeister','SCE004463','Alan Detheridge','SCE004482','Clive Mather','SCE004505','Andrew Osborne','SCE004596','. Hotdesk','SCE004596','Ruth Crawford','SCE004596','Joanne Taylor','SCE004596','Anne.T Riley','SCE004596','Josephine Bardswell','SCE004703','Tim Ford','SCE004726','John.M Overton','SCE004773','Robert.S Pritt','SCE004801','Joanne Crompton','SCE004801','Michael Ashworth','SCE004801','Karin Hawkins','SCE004801','Alison Merrington','SCE004801','Bradford Nielson','SCE004824','Hans Von Der Linde','SCE004824','Robin.H Aram','SCE004860','Graham Van'T Hoff','SCE004927','James Smith','SCE005006','James Dorrian','SCE005059','Walter Van De Vijver','SCE005090','Piet Koeleman','SCE005108','Tony Hanna','SCE005145','Enrique Morales','SCE005163','Judy Boynton','SCE005177','Peter.S Marshall','SCE005232','Malcolm Brinded','SCE005308','Alan Mawdsley','SCE005319','Richard Wiseman','SCE005331','Martin Bachmann','SCE005364','Angela Wilkinson','SCE005416','Charles Watson','SCE005521','Mike Forbes','SCE005524','Lesley Brook','SCE005917','Jeroen Van Der Veer','SCE005950','Yasmine Hilton','SCE005961','Mark Williams','SCE006008','Sofia Sattarova','SCE006011','. Hotdesk','SCE006011','Clare Reader','SCE006279','Clare Vick','SCE006410','John Withrington','SCE006424','Paul Murray','SCE006425','Simon Henry','SCE006496','. Hotdesk','SCE006530','Peter De Wit','SCE006537','Scott Roberts','SCE011882','Anton Keizer','SP003597','Mark Pattenden','SP008685','Richard Powles','SP175015','Bill Townsley','SP681592','David Fletcher','SP720013','Peter Hillman','STAS10239','John (Blair) MacIntyre ','STAS10340','John De Cuba','STAS10392','Mike Conway','STAS10719','Andy Roberts','STAS10816','Mike Warwick','STAS10853','Jan Kopernicki','STAS10948','NA']
function showResult2(sel){
document.getElementById("display").innerHTML = " " + SECT.find([sel.options[sel.selectedIndex].value]);
}
//this creates a new array function for the arrSec Array
SECT.find = function(what){
var i=0;
for (;this[i]!=what && i<this.length-2;i+=2){}
if (this[i]==what) return this[i+1]; else return false;
}
</script>
Thanks for any help
Peter
Save posting all the code I will try to explain first, I have a drop down menu that is built from a database and contains peoples names, at he same time I have also built an array in vbscript that contains the numbers and names and convert this into a JS array and this is used in a find funtion. each name has an id number associated with it, the idea is that when somebody selects a name from the dropdown list the number appears in a field below, now I have used this code in several pages and everything works fine.
However I am using it with different data and get an error saying 'object expected' I looked through the array and everything looked fine except part of one of the surnames was in Parenthesis (Blair)MacIntyre, so I put a condition on the selet option to make sure that this name was not returned and when I tried it again it worked.
My question is will having the name set out this way cause the error and if so how can I get around it without amending the name:
This is the script and array as it appears in the page I have marked the name in red that I suspect is causing the problem:
<script type="text/javascript">
var SECT = ['Mary-Grace Anderson','113784','Zeffrey Lucas','115521','Andy Dodd','118007','Graham Robinson','124423','Dave Martin','132261','Dirk Smit','134706','Darryl Wilkinson','134783','Dick Wynberg','134783','Gareth Pleavin','136629','Peter Slaiby','144210','Peter Jackson','144210','Anthony Charnley','144210','Chris Rowsell','146302','Malcolm Parker','146478','Eric Waugh','146478','Paul Newman','148305','Brian Humphries','149576','Dave Casson','149581','Eric Clark','149581','Tony Cramp','149581','Cliff Edwards','149581','Brian Teeder','149581','Vince Rylance','149581','Bob Sheffield','149581','Jonathan Phillips','149586','Ray Reynolds','149586','Steve Walters','149586','Jonathan Cavanagh','149586','Jon Mason','152583','Robbie McFegan','153068','Mike Hopprich','153333','Jim Beresford-Lambert','157117','Luuk Karsten','157267','Paul Carter','158232','Tom Botts','158524','Kieron McFadyen','158524','Mark Haselden','160336','Mark Haselden','160336','Paul Snaith','161191','Cliff Dorman','161279','Mick McMahon','162665','Bob Oorschot van','165987','Andrew Kerr','167587','Peter Allen','167587','David Martin','169488','Sue Paterson','171500','Nicola Gordon','171521','David Bostock','173444','Didrik Reymert','173576','Karen Leadbitter','173766','Kevin Wright','173804','Roger Patey','173897','Greg Hill','173899','Engelhardt Robbe','173900','Mike Conway','173901','Tom Hyde','175340','Ruth Leach','176937','Ruth Leach','176937','Simon Barnard','177002','Stuart Tester','177315','Toba Akinmoladun','178601','Ian Bradshaw','178954','Jim De Haseth','180543','Jim De Haseth','180543','Graham Smith','180543','Steve Starkey-Jones','181465','Stephen Whyte','181997','Line Sorensen','71986A','Andrew Cates','71986A','James Nyhan','71986A','Andrew Moretti','71986A','William Taylor','75047','Ken Rivers','80529','Paul Zealand','83740','Dick Leitch','84311','Colin Main','87638','John Harmer','87638','Adrian Loader','SCE000050','David Beer','SCE000335','John Wills','SCE000335','Michiel Moolenaar','SCE000350','Santurnino De Andres','SCE000358','David Young','SCE000358','Andrew Robson','SCE000405','Chris Worsley','SCE000466','Pat O'Driscoll','SCE000585','Ben Van Beurden','SCE000607','David Lawrence','SCE000608','Chris.R Ellins','SCE000608','Mike Napier','SCE000613','Bill Colquhoun','SCE000783','Simon Smith','SCE000792','Ronald Blakely','SCE000898','Lisa Davis','SCE000898','Hans Vlemmings','SCE000923','Neil.R Gaskell','SCE000966','Xavier Le Mintier','SCE001002','Joris Kniep','SCE001102','Wouter De Vries','SCE001102','Giles Craven','SCE001258','Mary Jo Jacobi','SCE001284','Susan Lamb','SCE001312','Nicola Lancaster','SCE001312','Mike Green','SCE001312','Michiel Mak','SCE001370','Julienne Baron','SCE001493','Robert Craig','SCE001507','. Modem','SCE001592','Phil.B Watts','SCE001592','Beat Hess','SCE001905','Albert Bressland','SCE002002','Renger Bierema','SCE002160','Andrew Blazye','SCE002171','Leslie Van De Walle','SCE002264','Martin Foley','SCE002267','Stan Bradbury','SCE002268','Steve Harman','SCE002270','Graeme Sweeney','SCE002457','Mike Wilkinson','SCE002811','Paul.D Skinner','SCE002813','Rob Routs','SCE002813','Rachel English','SCE002990','Guy Outen','SCE002990','Andrew Manley','SCE003068','Jyoti Munsiff','SCE003207','Richard Mann','SCE003213','Michael O'Callaghan','SCE003307','Cornelia Mckendrick','SCE003317','Justine Berkovitz','SCE003317','Keith Ruddock','SCE003317','Gillian Thorn','SCE003317','Ronald Schellekens','SCE003383','Abby Street','SCE003427','Bob Fryer','SCE003516','Ken Dean','SCE003526','Trevor Hobson','SCE003559','Nic Turner','SCE003837','John.D Hofmeister','SCE004463','Alan Detheridge','SCE004482','Clive Mather','SCE004505','Andrew Osborne','SCE004596','. Hotdesk','SCE004596','Ruth Crawford','SCE004596','Joanne Taylor','SCE004596','Anne.T Riley','SCE004596','Josephine Bardswell','SCE004703','Tim Ford','SCE004726','John.M Overton','SCE004773','Robert.S Pritt','SCE004801','Joanne Crompton','SCE004801','Michael Ashworth','SCE004801','Karin Hawkins','SCE004801','Alison Merrington','SCE004801','Bradford Nielson','SCE004824','Hans Von Der Linde','SCE004824','Robin.H Aram','SCE004860','Graham Van'T Hoff','SCE004927','James Smith','SCE005006','James Dorrian','SCE005059','Walter Van De Vijver','SCE005090','Piet Koeleman','SCE005108','Tony Hanna','SCE005145','Enrique Morales','SCE005163','Judy Boynton','SCE005177','Peter.S Marshall','SCE005232','Malcolm Brinded','SCE005308','Alan Mawdsley','SCE005319','Richard Wiseman','SCE005331','Martin Bachmann','SCE005364','Angela Wilkinson','SCE005416','Charles Watson','SCE005521','Mike Forbes','SCE005524','Lesley Brook','SCE005917','Jeroen Van Der Veer','SCE005950','Yasmine Hilton','SCE005961','Mark Williams','SCE006008','Sofia Sattarova','SCE006011','. Hotdesk','SCE006011','Clare Reader','SCE006279','Clare Vick','SCE006410','John Withrington','SCE006424','Paul Murray','SCE006425','Simon Henry','SCE006496','. Hotdesk','SCE006530','Peter De Wit','SCE006537','Scott Roberts','SCE011882','Anton Keizer','SP003597','Mark Pattenden','SP008685','Richard Powles','SP175015','Bill Townsley','SP681592','David Fletcher','SP720013','Peter Hillman','STAS10239','John (Blair) MacIntyre ','STAS10340','John De Cuba','STAS10392','Mike Conway','STAS10719','Andy Roberts','STAS10816','Mike Warwick','STAS10853','Jan Kopernicki','STAS10948','NA']
function showResult2(sel){
document.getElementById("display").innerHTML = " " + SECT.find([sel.options[sel.selectedIndex].value]);
}
//this creates a new array function for the arrSec Array
SECT.find = function(what){
var i=0;
for (;this[i]!=what && i<this.length-2;i+=2){}
if (this[i]==what) return this[i+1]; else return false;
}
</script>
Thanks for any help
Peter