Using a line of Javascript & PHP in a WordPress page (6 posts)

  1. sildona
    Posted 3 years ago #

    I have a button that validates prior to processing.

    <input type='button' onClick='validateAndSubmit();' value='Process' />

    Evidently, Javascript is not a core feature of WordPress and requires some little dinking around.

    I have read the Codex on how to call a Javascript file, but this is embedded in a PHP file.

    How do I get this line to work in my WordPress page?


  2. noahjonah
    Posted 3 years ago #

    When dealing with Javascript/jquery, you will need to split up that file and place each piece where it needs to go.

  3. Including Javascript in a post is a bit tricky. I think it's ok to have the js file in the php file, but if you really want to add it to the post, have a look at the instructions here:


  4. sildona
    Posted 3 years ago #

    It's a pain the _ _ _. Working with WordPress is analogous to buying a stripped-down car. If someone wants an airbag or maybe a horn or some seatbelts, they're required to install these pieces themselves. Pretty ridiculous. Really WordPress?.

  5. Considering that WordPress powers a huge portion of the Internet, I think that you'll find a lot of people would disagree. There is a learning curve of course...

    As I mentioned earlier, it might be easier for you to make a custom template and just enter your js in the php file.

  6. sildona
    Posted 3 years ago #

    "Learning curve" is much different than "some assembly required."

    Learning WP consists of mastering its inherent operations, its admin panel, for instance, which is WordPress' seat. Basically, the learning curve for WordPress is about 30 minutes. It's learning how to operate WP as a functional program.

    Some assembly required means such things as having to install code in a WordPress template because the essential functionality to recognize other certain code isn't within the primary vehicle. Some assembly required means having to construct things like "a custom template" and do a couple more tasks to make the primary vehicle work properly. Some assembly required extends beyond Javascript to Ajax to PHP--all of which require some sort of additional tinkering if one is to incorporate any of it in a page (PHP being kind of the exception because some third-party plugins are available that make the task somewhat more automated, but the fact remains that someone had to assemble these because WordPress didn't easily offer the needed functionality). But my point is clear ... some assembly required ... that's WordPress.

    I didn't say WordPress isn't functional. It is. I didn't say it isn't useful. It is. I didn't say it isn't better than other options ... it has a lot of advantages. Another useful analogy might be particle-board furniture, which is also useful and very popular--but like WordPress, there is some assembly required. Just because particle-board furniture populates many American homes ... just because many people who buy and assemble this furniture don't find it particularly troublesome doesn't alter the fact that it requires some assembly.

Topic Closed

This topic has been closed to new replies.

About this Topic