Jump to content

Parsing a number from a string?


MrAdam

Recommended Posts

Great stuff! Works great except, when there's no match it just doesn't seem to wanna play! checked firefox error console and it says:Error: str.match(patt1) is nullHow could I run a conditional to sort of be able to say wether or not there is anything there (for example the stirng may just be: "Inbox") ??Thanks for your help pal! Adam

Link to comment
Share on other sites

var patt1 = /inbox\[(\d*)\]/;if (result = document.getElementById("newMessages").innerHTML.match(patt1)[1]) {	var currentCount = result;} else {	var currentCount = 0;}alert(currentCount);

But again, nothing happens and in the error console says patt1 is null ???I've also tried your idea Deidre's Dad, but again said = null ..Quite confused..Anybody any ideas?Cheers for the help!!Adam

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...