Problems with <form> and Dynamically-generated links

笑着哭i 提交于 2020-01-06 19:52:49

问题


Related directly to this post, I am having trouble implementing some sound advice given from @sean, because as you can see on this page:

http://www.onestopfasteners.com.au/checkout.php - I have wrapped the form tags around the table element, but the form just doesn't seem to be working, and nothing ever gets "POST"ed either. I've changed the code around abit to experiment, but haven't found a solution, and no search anywhere has proven to be useful yet.

I'd appreciate any help at all. I'm completely baffled!

Thanks!

P.S. I thought that maybe the fact that I am wrapping form elements around dynamically generated content could be why the form isn't working, but that doesn't make much sense to me and, I've done it before, so that can't be it, can it?

Code:

I know, it's long, apologies in advance. :)

<?php
   // (c) code removed ;) problem solved - thanks to everyone who helped!
?>

回答1:


I think your problem is with:

function submit() {

             document.myform.submit();

             }

Try:

function submit() {

                 document.getElementById('ct_form').submit();

                 }

It looks like you are using jQuery in the page so you could also use:

function submit() {
    $('#ct_form').submit();
}



回答2:


Your using javascript to submit the form, but you are referencing document.myform which doesn't exsist.

try this instead.

document.getElementById('ct_form').submit() 



回答3:


// do sumbit first form of document 
document.forms[0].submit()

document.getElementById is not necessary here. document.myform relies on NAME attribute of FORM element, by the way



来源:https://stackoverflow.com/questions/4189771/problems-with-form-and-dynamically-generated-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!