...

View Full Version : Scan until character found?



KennyG
06-30-2004, 01:39 PM
Hi folks.

I need some code done for this problem.

Instead of;

element would be; DM016A_RF_LIMS

element=formName.LIMIT_lb.options[i].text
compare=element.substr(0,5);

I need;

element=formName.LIMIT_lb.options[i].text
compare=element (string up until the first underscore, NOT THE 1st FIVE CHARACTERS as above)

?

Cheers

sad69
06-30-2004, 05:53 PM
indexOf may be what you're looking for:


var element = formName.LIMIT_lb.options[i].text
var e = element.indexOf('_');
var compare = element.substring(0, e);


Hope that helps,
Sadiq.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum