Why does button "onclick" execute a Submit on Bug Report page

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
Posts: 8
Joined: 30 May 2017, 16:36

Why does button "onclick" execute a Submit on Bug Report page

Post by mantisNoob2 »

I need to autofill a field in the bug report page based on the input from another field. I figured an easy way to trigger the update is by adding an update button in bug_report_page.php. However, every onclick method I have tried simply executes the bug_update.php, and attempts to submit the bug.

I tried calling a method that I added to custom_field_api.php.

I tried running a separate php document.
<input type="submit" class="btn btn-secondary btn-sm" value="Get Hours" onclick='get_support_hours.php' </input>

<button onclick="window.location.href='https://w3docs.com';">Click Here</button>

I tried a javascript function.
<button type="submit" onclick="myFunction()">Get Hours</button>

<script type="text/javascript">
function myFunction() {
<?php echo "hello" ?>

I also tried using ajax. Everything I tried causes my button to act as if it is the existing Submit button. Please excuse my ignorance, but why is this, and how can I get around it?

Thanks in advance!
Post Reply