1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how do you call a javascript method within php code?

Discussion in 'JavaScript' started by lost, Nov 10, 2005.

  1. #1
    i need to call a javascript method within php code, but with no user interaction. i.e. no click of a button, no user input, nothing.

    i just need to do a call to the function, is it at all possible??
     
    lost, Nov 10, 2005 IP
  2. torunforever

    torunforever Peon

    Messages:
    414
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you like the javascript syntax better or something? Why would you want to do that.

    PHP and javascript are in two different worlds (server vs client). There is no direct interaction between the two. Your PHP can echo out javascript, and what you'll end up with is a generated page with that javascript, and when it arrives at the client, the javascript will do what you want. If it needs to execute as soon as the page loads, then use onload.

    I realize my answer is a little vague, but so is your question.
     
    torunforever, Nov 10, 2005 IP
    Nintendo likes this.
  3. rederick

    rederick Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php echo "<script>javascriptfunction();</script>"; ?>
    PHP:
     
    rederick, Nov 11, 2005 IP