oconndav Posted September 15, 2007 Share Posted September 15, 2007 Hi,I hoping this is a fairly simple request but I have not been able to find a solution anywhere...I am trying to execute the if statement below so that it executes if the value of "firstname" begins with the letter A. I had hoped that adding the * wildcard would do the trick but no luck.Basically I have this running inside a loop which goes through the complete XML file, I want it to only process values begining with certain letters.If anyone coudl help me out it would be much appreciated. aa=x[i].getElementsByTagName("firstname") bb = aa[0].firstChild.data if (bb=="A*") { Link to comment Share on other sites More sharing options...
boen_robot Posted September 15, 2007 Share Posted September 15, 2007 The real question is how find if any string starts with another. I don't know if JS has a function explicitly for that, but you should be able to do it with match() like so: if (bb.match("^A.*")) It's probably not the most efficient way, but it should work non the less. Link to comment Share on other sites More sharing options...
oconndav Posted September 15, 2007 Author Share Posted September 15, 2007 thanks - that works great. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.