Web Design and Web Development Forum

  1. #1
    Join Date
    Aug 2005
    Location
    Walton, New York
    Age
    23
    Posts
    138
    Rep Power
    7
  2. NedreN is on a distinguished road
  3. Substr() Problem

    I'm having a problem with the function substr() working in different browsers, and I want to see if anyone else can enlighten me as to why it's not working correctly in Internet Explorer.

    Here's a snippet of the function that isn't working:
    Code:
    ...
          var extension;
          extension = element.value.substr(-3);
          alert(extension);
    ...
    "Element" is an HTML input that contains whatever value. What I'm trying to do here is return the last 3 characters of whatever string is in the text field input.

    It works fine in Mozilla Firefox, but in Intenet Explorer "extension" holds the entire value of "element.value", which I don't understand.

    Anyone have any ideas as to why this is happening?

    Edit: After searching around a bit I believe I've come to an anwser. Internet Explorer I guess has a bug where substr(num) is used, and num is a negative value, it just doesn't work and returns the entire string.
    Last edited by NedreN; 06-23-2006 at 04:57 PM.
    Reply With Quote Reply With Quote

Similar Threads

  1. PHP and Javascript Problem
    By johnnie in forum PHP Scripting
    Replies: 3
    Last Post: 03-28-2006, 11:32 AM
  2. Problem with hackers...
    By lejla in forum General Web Programming
    Replies: 18
    Last Post: 01-29-2006, 01:33 AM
  3. Problem
    By illusion in forum Computer Corner
    Replies: 12
    Last Post: 09-22-2005, 11:33 AM
  4. EXCEL/VB Macro problem
    By gram333 in forum Visual Basic Programming
    Replies: 0
    Last Post: 06-24-2005, 07:09 AM
  5. Funny Problem
    By Logan in forum PHP Scripting
    Replies: 4
    Last Post: 01-25-2005, 08:45 AM