简体   繁体   English

问题 <form> 和动态生成的链接

[英]Problems with <form> and Dynamically-generated links

Related directly to this post , I am having trouble implementing some sound advice given from @sean, because as you can see on this page: 直接与这篇文章相关 ,我无法实现@sean提供的一些合理建议,因为您可以在此页面上看到:

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. http://www.onestopfasteners.com.au/checkout.php - 我已经在表格元素周围包装了表单标签,但表单似乎没有工作,也没有任何东西可以“POST”。 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. 我已经改变了abit的代码来进行实验,但是还没有找到解决方案,并且任何地方的搜索都没有被证明是有用的。

I'd appreciate any help at all. 我会感激任何帮助。 I'm completely baffled! 我完全困惑了!

Thanks! 谢谢!

PS 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? PS我认为可能事实上我将表单元素包裹在动态生成的内容周围可能是表单无法正常工作的原因,但这对我来说没有多大意义,之前我已经完成了,所以可以'不管怎样,可以吗?

Code: 码:

I know, it's long, apologies in advance. 我知道,这很长,提前道歉。 :) :)

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

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: 看起来您在页面中使用的是jQuery,因此您也可以使用:

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

Your using javascript to submit the form, but you are referencing document.myform which doesn't exsist. 您使用javascript提交表单,但是您引用的文档不存在的document.myform。

try this instead. 试试这个吧。

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

document.getElementById is not necessary here. 这里不需要document.getElementById document.myform relies on NAME attribute of FORM element, by the way 顺便说一句, document.myform依赖于FORM元素的NAME属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM