regex question - trying to find ".mp3" in a SELECT box



I've a form for creating podcast episodes. The user can pick an MP3
from a drop down box (an HTML select box). I'm trying to add some error
checking. In the code below, I try to get the value of the select box,
and then I try to see if it contains the string ".mp3". I'm getting the
alert message every time. Why is that?


var inputToCheckReference =
document.getElementById(idOfFirstInputThatWeShouldCheckString);
if (inputToCheckReference != false && inputToCheckReference !=
undefined) {
var valueOfInputToCheckString = inputToCheckReference.value;


var regXString = characterThatsNeededForThisField;
var regX = new RegExp(regXString, "g");
var results = valueOfInputToCheckString.match(regX);

var resultsTypeof = typeof(results);

if (resultsTypeof != Array) {


} else {
alert("No mp3s");
}




The HTML on the source code looks like this:




<tr>
<td valign="top"><h3>Choose your media file to
Podcast...</h3></td>

<td><select name="formInputs[cbLinksToWhatUrl]"
id="browseserver"><option selected>-No choice made-</option>
<option value="petrol.mp3">petrol.mp3 - 4168 k</option>
<option
value="found_you_abel_and_sophia.mp3">found_you_abel_and_sophia.mp3 -
3288 k</option>
<option value="CrowdedHouse_LockedOut.mp3">CrowdedHouse_LockedOut.mp3
- 3156 k</option>
<option
value="CrowdedHouse_LockedOut_12_05_06_-_05_05_52.mp3">CrowdedHouse_LockedOut_12_05_06_-_05_05_52.mp3
- 3156 k</option>
<option
value="CrowdedHouse_LockedOut_12_05_06_-_05_05_27.mp3">CrowdedHouse_LockedOut_12_05_06_-_05_05_27.mp3
- 3156 k</option>

<option
value="CrowdedHouse_LockedOut_15_05_06_-_06_05_21.mp3">CrowdedHouse_LockedOut_15_05_06_-_06_05_21.mp3
- 3156 k</option>
<option
value="nouvellevague_dancingwithmyself.mp3">nouvellevague_dancingwithmyself.mp3
- 4562 k</option>
<option value="Shadowshorter.wmv">Shadowshorter.wmv - 971 k</option>
<option value="mybrother.mp3">mybrother.mp3 - 3263 k</option>
<option
value="DontForgetWhereYourFrom.mp3">DontForgetWhereYourFrom.mp3 - 13742
k</option>
<option
value="mybrother_25_05_06_-_06_05_28.mp3">mybrother_25_05_06_-_06_05_28.mp3
- 3263 k</option>

<option
value="mybrother_30_05_06_-_02_05_04.mp3">mybrother_30_05_06_-_02_05_04.mp3
- 3263 k</option></select></td>
</tr>

.



Relevant Pages

  • Re: on page exit
    ... of which JavaScript is only one. ... used in HTML with intrinsic event handler attribute values, ... var clickedLink = null; ...
    (comp.lang.javascript)
  • Re: Various DOM-related wrappers (Code Worth Recommending Project)
    ... var filter, filterLegacy; ... // Filter wrapper, which is included at this stage as it is needed ... // Returns the HTML element by default or optionally ...
    (comp.lang.javascript)
  • Proto et EAI
    ... Le graphisme vrml est inclu dans une page html. ... DIV du document HTML est bien mis à ... var sTempVrml = GenererCourbe2; ...
    (comp.lang.vrml)
  • Re: Help with two page form
    ... <HTML> ... <HEAD> ... function load1() { ... var load1 = window.open('http://www.webdesignsbyjc.com/DBSample/ ...
    (comp.lang.php)
  • Re: Referring to form select fields.
    ... html += GetAllW4StForm ... var stlinkfound = false ... `this' refers to the global object. ... property access is equivalent to ...
    (comp.lang.javascript)