2在一个页面中形成操作导致错误

时间:2013-03-20 14:18:44

标签: javascript forms paypal

我在一个页面中有2个Pay Pal表单,第一个正常工作但第二个表示错误:

TypeError: 'undefined' is not an object (evaluating 'document.secondPriceForm.submit')

这是我的代码:

                        <div id="deatails">
                         <?php while(has_sub_field("meta_data")): ?>

                            <table>
                            <!-- table row for price START-->
                            <tr>
                            <?php if(get_row_layout() == "pay_pal_data"): // layout: Content 
                                    if(get_sub_field("sold_out")):
                                    echo 'Sold out';
                                    else:?>

                              <form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="regularPriceForm"  name="regularPriceForm">
                                <td class="price price-label">
                                        <input type="hidden" name="cmd" value="_xclick">
                                        <input type="hidden" name="business" value="<?php echo @"tamararie@gmail.com" ?>">
                                        <input type="hidden" name="item_name" value="<?php the_title(get_field('cover_image')) ?> ">
                                        <div class="meta-text item-field_price"><?php the_sub_field("regular_price_description"); echo (' : ');  the_sub_field("regular_price"); echo '$' ?></div>
                                        <input type="hidden" name="amount" value="<?php the_sub_field("regular_price"); ?>">
                                        <input type="hidden" name="no_shipping" value="2">
                                        <input type="hidden" name="no_note" value="0">
                                        <input type="hidden" name="currency_code" value="<?php echo 'USD' ?>">
                                        <input type="hidden" name="country" value="<?php echo 'US' ?>">
                                </td>
                                <td class='quantity price-label'>     
                                    qty. <input type="number" name="quantity" value="1" maxlength="9" min="1" max='9'>
                                </td>
                                <td class="submitButtonTd price-label">
                                        <input type="hidden" name="bn" value="PP-BuyNowBF">
                                        <a class='meta-text' href='javaScript:document.regularPriceForm.submit();'>Purchase</a>
                                </td> 
                              </form> 
                            </tr>
                            <!-- END OF table row for price -->


                            <!-- table row for additional price START-->
                            <?php if(get_sub_field('additional_price')):?>
                                <tr>
                                    <form>


                                    <td class="form-description-td">
                                        <form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="secondPriceForm">
                                                <input type="hidden" name="cmd" value="_xclick">
                                                <input type="hidden" name="business" value="<?php echo @"tamararie@gmail.com" ?>">
                                                <input type="hidden" name="item_name" value="<?php the_title(get_field('cover_image')) ?> ">
                                                <div class="meta-text item-field_price"><?php the_sub_field("additional_price_description"); echo (' : '); the_sub_field("additional_price");  echo '$' ?></div>
                                                <input type="hidden" name="amount" value="<?php the_sub_field("additional_price"); ?>">
                                                <input type="hidden" name="no_shipping" value="2">
                                                <input type="hidden" name="no_note" value="0">
                                                <input type="hidden" name="currency_code" value="<?php echo 'USD' ?>">
                                                <input type="hidden" name="country" value="<?php echo 'US' ?>">

                                    </td>
                                    <td class='quantity price-label'>     
                                    qty. <input type="number" name="quantity" value="1" maxlength="9" min="1" max='9'>
                                   </td>
                                    <td class="submitButtonTd">
                                                <input type="hidden" name="bn" value="PP-BuyNowBF">
                                                <a class='meta-text' href='javaScript:document.secondPriceForm.submit();'>Purchase</a>
                                    </td> 
                                    </form> 
                                </tr>
                                <!-- END OF table row for additional price -->
                                <?php endif; ?>

                            <?php endif; ?>
                            <!-- END OF table row for pay_pal_data-->




                            <!-- table row for print_meta START-->
                            <?php elseif(get_row_layout() == "print_meta"): // layout: File ?>


                            <tr>

                                <td class='meta-text'> Size: <?php if(get_sub_field("size")){ the_sub_field("size");} ?></td>
                                <td class='meta-text right-meta-text'><?php  if(get_sub_field("series_size")){ echo 'Limited edition of '; the_sub_field("series_size");} ?> </td>
                            </tr>

                            <!-- END OF table row for print_meta-->


                            <?php endif; ?>

                            </table>

                            <?php endwhile; ?>

这是该页面的链接: Website Page

链接是每本书下的2个购买链接。

1 个答案:

答案 0 :(得分:0)

将第二种表单的id设置为secondPriceForm。您目前只设置name