• imjscn

    (@imjscn)


    I want to add this action on Comment Submit Botton: onclick=”myfunction()”

    I guess this can be done by editing the theme’s comment.php file, right?

    In the comment.php file, I find the section about the Submit botton, the code is like this:

    <div id="submitbox">
    <input name="submit" type="submit" id="submit" class="button" value="<?php _e('Submit Comment', 'mystique'); ?>" />
    .....
    </div>

    May I ask a peice of code to apply myfunction() on this Submit Botton?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Marventus

    (@marventus)

    Hi there.

    I thought I had found a solution to your problem but I realized there was a very big mistake in my approach.

    Allow me to work a little bit on it and I’ll post a solution in a while.

    Marventus

    (@marventus)

    Yeah, so there was something bothering me about your code up there and I couldn’t put my finger on it.
    Then it hit me: I think you’re mixing up server side and client side coding: “onclick” is a Javascript trigger that runs on the client side, and that triggers a Javascript piece of code, and PHP runs solely on the server and has no clue of what is going on on client-side events (such as clicking buttons, for instance).
    The way I see it, you have two choices:
    1. Keep the onclick command but recode your myfunction.php in JS language, or;
    2. Keep both the Onclick command and the php function and use Ajax for php/JS interactions. There’s plenty information available on Ajax out there, so it shouldn’t be hard to find an implementation that works for you.
    Sorry it took me a while to realize what the problem was, but I am not very knowledgeable in coding (yet), although I’m trying to learn because I find it fascinating, 🙂
    LMK if this is helpful.
    Good luck!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add an action on the Submit botton?’ is closed to new replies.