WordPress.org

Ready to get started?Download WordPress

Forums

Javascript Causing Reload? (1 post)

  1. barnstone
    Member
    Posted 6 years ago #

    Hi,

    I have a wordpress page that has a form on it. The user fills in the first three fields then clicks on a "Calculate" button which calls a javascript function that does the calculations and populates some other form fields with the results. At least that's how it works outside of WordPress.

    Inside WordPress, when the button is pressed the calculations are performed and the fields are populated correctly, but then all the form fields go blank and the URL changes from

    http://localhost/barnstone2/calculator

    to

    http://localhost/barnstone2/calculator?param1=blah&param2=blah&....

    So it somehow seems to be redirecting to the same page but with both the entered and calculated form field values encoded as parameters in the URL.

    The javascript is in a separate file, and the form has no action or method defined. The call to the javascript is done like this:

    <a onclick="javascript:compute()"><button>Calculate</button></a>

    It works find outside of wordpress. I've tried both putting the form in the page content and in the template. It's running on Apache and I'm using pretty permalinks.

    Any ideas? Any help or pointers in the right direction would be greatly appreciated.

    Thanks,

    John

Topic Closed

This topic has been closed to new replies.

About this Topic