Results 1 to 5 of 5

Thread: Function problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    30

    Function problem

    can anyone help me here and tell me why this doesn't work?

    <%
    sub fnt()
    response.redirect("http://www.microsoft.com")
    end sub
    %>
    <button onClick='<%fnt()%>'/>

    So when i click the button i should be redirected to microsoft.com?

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    30

    Re: Function problem

    I forgot to tell.. It works but it redirects imediatly to microsoft.com when i open the page.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Function problem

    First, there's no such thing as <button>!!

    Second, you are placing the "action" of the subroutine fnt (which is server side) in the onclick attribute of button. Which makes as much sense as George Bush giving a state of the union address.

    Do this instead:

    Code:
    <script language="JavaScript">
    
    function fnt(){
    document.location.href='http://www.mendhak.com';
    }
    
    </script>
    
    <input type="button" value="Click me" onClick="javascript:fnt()"/>

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    30

    Re: Function problem

    ok tnx a lot

  5. #5
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    Re: Function problem

    Hi,

    If your doing this in VBscript, which it looks like you are, youll have to check whether the button is pressed or not first, as when the scipt loads, the funciton will return the value of -1 and execute imeediately.


    if request.form (buttonname) <> "" then
    'redirect coding.

    end if
    end function

    thjis should work...

    ta

    kai

Posting Permissions

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



Click Here to Expand Forum to Full Width