• Hi

    I’m a webdev, but not a WordPress user & I’m completely confused by http://codex.ww.wp.xz.cn/Using_Javascript .. it assumes too much that I don’t know.

    I’m working on an existing WordPress blog and there’s a page that contains a Javascript calculator that doesn’t work now we’ve moved to WP. The Javascript is on the page, and not required elsewhere.

    Here’s how much I don’t know .. I’ve edited the page and put in an wp_enqueue_script() call, and also one in <php ?> and both were published to the page.

    Would anyone care to walk me through it or give me a hint? Tbh, wp_enqueue_script() seems overkill, it’s just one-off script on the one page.

Viewing 9 replies - 16 through 24 (of 24 total)
  • thanks I will. I thought that because is the same topic and the same problem… it could be using the same post.

    One way would be to translate all the inline javascript code into jQuery code that can be put into an external javascript file or in the header/footer, using the methods I mentioned above or the enqueue script method.

    cheers

    Thread Starter jnascarb

    (@jnascarb)

    Thanks LadyOpita, yes, I think we have the same problem so thanks for speaking up.

    I’m off to read the Using_Javascript thing.

    Birgire, I know jQuery’s great and all, but it feels like a big library for what I want to do. Anyway, my code isn’t jQuery code, it’s proper Javascript, it doesn’t feel right to re-write that to use a big library when it already works fine, WordPress is the problem* πŸ™‚

    * How to make friends and influence people on a WordPress forum πŸ™‚

    Whether you use jQuery or not, you should still place your javascript in an external file and enqueue it using wp_enqueue_script().

    @jnascarb

    another way: you could write a page template for your form (including your inline javascript)

    http://codex.ww.wp.xz.cn/Pages#Creating_Your_Own_Page_Templates

    but an external javascript file is cleaner πŸ˜‰

    cheers

    Thread Starter jnascarb

    (@jnascarb)

    Ta, the “Creating a Multiple Script File” part of http://codex.ww.wp.xz.cn/Using_Javascript is where I’m at, I’ll let you know if it works and if not, I’ll come back to those, tvm πŸ™‚

    Hi all, total JS noob and same problem. And in other online forums the etiquette is to try and NOT start new threads for the same issue. Is WP Support different?

    I’ve got JavaScript code that I want to work on a single post. Tried manually entering in Text field, nothing. Tried Javascript and CSS plugin, didn’t work. Could someone explain the “external file” method?

    If helpful, I’m trying to replicate the wine value comparison tool shown on this page, widget down the right side: http://www.wellesleywinepress.com/2009/05/modeling-value-introducing-wwpqpr.html

    Thanks in advance.

    Is WP Support different?

    Yes, per: http://codex.ww.wp.xz.cn/Forum_Welcome#Where_To_Post

    It helps keep the forums better organized and avoids the difficulties in having multiple conversations at the same time with what are often not actually the same situations.

    Here’s some general info –

    http://codex.ww.wp.xz.cn/Using_Javascript

    But please do start a new thread if you need more help.

    Thanks WPyogi, I’ll follow the rules and do so. But just some feedback — when I have problems I’m constantly finding relevant threads, that unfortunately always seem to be closed. Other forums don’t shut down the conversation like WP Support.

    Appreciate the link.

Viewing 9 replies - 16 through 24 (of 24 total)

The topic ‘adding Javascript to a single page’ is closed to new replies.