23 users online (1 members and 22 guests)  


  Results 1 to 5 of 5

Related

  1. Javascript event inside echo statement    Forum: PHP Forum
    Replies: 2
  2. Javascript onclick Event Handler:    Forum: Javascript Forum
    Replies: 3
  3. Replies: 2
  4. javascript onclick event to refresh iframe.    Forum: Javascript Forum
    Replies: 5
  5. Help-a href hide them please    Forum: Website Scripts Forum
    Replies: 7
  1. #1
    manjireee's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2008
    Posts
    2

    href + javascript onlick event

    Hello,

    am doing one program, where user types an alphabet or name in text field, then below at span , all the data related to alphabet or name will be retrived.
    so now i want to do is , in span, i want an href (link) , so wen i click on that link, i will call onClick() and i will alert the particular name .

    <a href="#" onClick="return view();" id="aa"><?php $response=$hint; ?></a>

    <script type="text/javascript">
    function view()
    {
    alert("inscript");
    var a=document.getElementByID(aa).value;
    alert(a);
    return true;
    }
    </script>

    what should i do,
    and can i put id or name to href, so i want to access that value in javascript through id or name


    thanks in advance

  2. #2
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: href + javascript onlick event

    You just missed on adding highlighted:
    Code:
    var a=document.getElementByID('aa').value;
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  3. #3
    manjireee's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2008
    Posts
    2

    Re: href + javascript onlick event

    ya, jus did that
    but am not able to enter into function view()

    1st line of function i hav put line, alert("in function");

    but onClick event does not enter that function.

  4. #4
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: href + javascript onlick event

    Could you please show to us the generated markup (HTML) instead of the PHP raw file.
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  5. #5
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: href + javascript onlick event

    You don't have anything entered in for a link. There is nothing for you to click on. How are you getting to the function as is?

    All this line does is assign the variable. Nothing will show up on screen: <?php $response=$hint; ?>



Tags for this Thread