Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy correct my JavaScript split function please

    Whats wrong with the code below? I'm trying to get the email service provider name.

    Code:
    <html>
    <head>
     
    <script type="text/javascript">
    function GetProvider {
    var fullemail = openinviter.email_box.value;
    var afterat = fullemail.split("@");
    var Provider = afterat[1].split(".");
    var showit = Provider[0];
    openinviter.provider_box.value=showit;
     
    }
    </script>
     
    </head>
     
    <body>
    <form action="" method="post" name="openinviter">
    <input type="text" name="email_box" onchange="GetProvider()" />
    <input type="text" name="provider_box" value="">
    </form>
     
     
     
     
     
    </body>
    </html>
    Thanks alot!

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by modykurnani View Post
    What's wrong with the code below?
    The error console will/is trying to tell you that.

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by Logic Ali View Post
    The error console will/is trying to tell you that.
    That helped. Thanks!!
    incase someone ever make this mistake , adding () to the function solved it
    Really stupid me lol

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Again, after adding it to my page the console is giving,

    Code:
    openinviter is not defined
    var fullemail = openinviter.email_box.value;
    any idea?
    nothing changed in the code though all the ame but giving the error

    thanks again

  • #5
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by modykurnani View Post
    That helped. Thanks!!
    incase someone ever make this mistake , adding () to the function solved it
    Really stupid me lol
    Now what happens if the entry doesn't include '@' ?

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    Quote Originally Posted by modykurnani View Post
    Again, after adding it to my page the console is giving,

    Code:
    openinviter is not defined
    var fullemail = openinviter.email_box.value;
    any idea?
    nothing changed in the code though all the ame but giving the error

    thanks again
    document.forms.openinviter ?
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •