I am working with this piece of code and it is not firing when I put it in the page I need which is static HTML. It does work if you create a plain HTML page, but it is not working on the page I need.

<form name="CTTPDD" action="https://example.com" method="post" target="_blank"><input type="hidden" value="##.##" name="campaign" /><input name="repeat" type="hidden" value="1"><input type="image" src="image.gif" value="submit" name="submit" /></form>  

What could it be?

Please can you help.

Dani AI

Generated

As 's snippet works standalone (as confirmed) but not on the dev page, something in that page is changing normal form behavior. When a submit button appears to do nothing the usual suspects are scripts, markup problems, CSS overlays, or name collisions that mask the form API.

Common culprits and quick checks:

  • JavaScript errors earlier on the page stopping script execution — check the browser console for exceptions.
  • An event handler calling preventDefault() or returning false on submit or a click; inspect event listeners in DevTools.
  • An input or element named submit that shadows the form's submit() method (a frequent gotcha). In the console the type should be function, not object.
  • A transparent overlay or CSS such as pointer-events / z-index blocking clicks on the image.
  • The form placed inside an invalid context (nested forms, inside disabled fieldset, or inside an anchor) or missing/incorrect markup earlier in the document that breaks the DOM.
  • target="_blank" interactions with popup blockers or a <base> tag altering behavior.

A small console test to detect the submit shadowing issue:

var f = document.querySelector('form[name="CTTPDD"]');
console.log('submit property is', typeof f.submit);

If that prints anything other than function, rename the input (for example to submitBtn) and test again. Practical fixes are renaming colliding fields, temporarily removing other scripts/styles to isolate the problem, replacing the image-input with a plain submit to see if the image is the issue, and validating the page HTML. For reference, the HTML form element and the submit() behavior are documented on MDN: form element and HTMLFormElement.submit.

Recommended Answers

All 6 Replies

Which part isnt working. I tried your code and when you click on the image, the form action executes.

Hello

It doesn't execute when i put it in to the page i need.

I cant send that page as its on my dev box.

Can you provide the revelant code from that page? Maybe there is something else on the page that is the problem.

afraid i cant :-(

I know where this leaves me.

Ok, sorry about that then. Not sure what else to advise you of.

Maybe I can help...
Are you trying to create a form submit button, correct?
If so, follow this tutorial

(i could be off topic)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.