Results 1 to 7 of 7

Thread: CSS Button onclick event href="#" onclick="

  1. #1
    Join Date
    Dec 2009
    Posts
    23

    CSS Button onclick event href="#" onclick="

    Hello to all,
    I want to call procedure from the href="#" onclick="", but I unable to do this. I want to call protected Sub ABCD() from the onclick event. I have tried following code:
    Code:
    <a class="button" href="#" onclick="ABC();"><span>GO</span></a>
    But this is not working. Please help me with CSS Button onclick event href="#" onclick="
    Thank you.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: CSS Button onclick event href="#" onclick="

    Code:
    <a class="button" href="#" onclick="ABC();"><span>GO</span></a>
    Hey why are you using href="#" ? There is no need to assign "#" to the href, Instead of it you have to use "Javascript" like following:
    Code:
    <a class="button" href="Javascript" onclick="ABC();"><span>GO</span></a>
    Now try to run program.

  3. #3
    Join Date
    Nov 2005
    Posts
    1,323

    Re: CSS Button onclick event href="#" onclick="

    You have to use following code to get rid out of this problem. In the following code I have assign "javascript:ABC('http://www.yahoo.com');" function to the onClick event. I also have use alert(ABCD) function.

    Code:
    <html>
    <head>
    <title>Untitled Documents</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <script>
    function ABCD(url)
    {
    alert(ABCD);
    }
    </script>
    <body>
    <a href="#" onClick="javascript:ABC('http://www.yahoo.com');"><span>GO</span></a>
    
    </body>
    </html>

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: CSS Button onclick event href="#" onclick="

    Hey the code you have given above tell about how function is called from the HTMl . In my case I am trying to call the procedure rather than the function and that's why I am getting this problem. Can anyone tell me whether I have to use procedure as a function. What is the process to do this? Please help me.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: CSS Button onclick event href="#" onclick="

    I will give you simle example of how to call procedure or function. Just try to understand it. In the following code when onclick is execute the control transfer to the check() function and code within it executed.
    Code:
    <html>
    <body>
    
    <script type="text/javascript">
    document.write("This is my first JavaScript!");
    check(){
    alert()
    }
    
    </script>
    <a onclick="check()"> Hello world<a>
    </body>
    </html>

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    Re: CSS Button onclick event href="#" onclick="

    In your code you have written following and it is wrong way to do this.
    Code:
    <a class="button" href="#" onclick="ABC();"><span>GO</span></a>
    In the above code you have assign "#" to the href and that's why you are facing this problem. In this case just use following code to call the procedure properly.
    Code:
    <a href="javascript:void(null)" onClick="alert('Examples')">Examples</a>

  7. #7
    Join Date
    Jan 2008
    Posts
    1,521

    Re: CSS Button onclick event href="#" onclick="

    Quote Originally Posted by Cornnelius View Post
    Hello to all,
    I want to call procedure from the href="#" onclick="", but I unable to do this. I want to call protected Sub ABCD() from the onclick event. I have tried following code:
    Code:
    <a class="button" href="#" onclick="ABC();"><span>GO</span></a>
    But this is not working. Please help me with CSS Button onclick event href="#" onclick="
    Thank you.
    Hey as per my knowledge you are not able to call a function with vb script until and unless you post the page.

Similar Threads

  1. Replies: 7
    Last Post: 04-01-2012, 09:14 PM
  2. Replies: 6
    Last Post: 18-05-2010, 12:27 AM
  3. href="javascript:func()" vs href="#" onclick="javascript:func()"
    By BansiJI in forum Software Development
    Replies: 6
    Last Post: 12-05-2010, 10:02 AM
  4. A Href And OnClick Button
    By Endowed in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:24 PM
  5. <A HREF="#" onClick="window.open ('sitename.html') ...>
    By Amy Adams in forum Software Development
    Replies: 4
    Last Post: 11-05-2010, 12:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,272,892.87377 seconds with 17 queries