0

ドロップダウンメニューが1つだけの同じフォームに、今すぐ購入ボタンとカートに追加ボタンを追加したい。現在、2 つのドロップダウン メニューがありますが、これは、今すぐ購入してカートに追加するボタンが必要な場合とまったく同じです。

したがって、基本的には、今すぐ購入して両方のボタンにリンクするカートに追加するためのドロップダウンメニューを1つだけ使用したいと考えています。

これは、[今すぐ購入] ボタンのみの HTML です。

<form id="form_35" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_self" style="margin:0;position:absolute;left:492px;top:112px;width:199px;height:68px; /*MainDivStyle*/" __AddCode="here">
    <!--MainDivStart-->
    <input type="hidden" name="bn" value="Serif.WebPlus">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="info@mysite.com">
    <input type="hidden" name="item_name" value="Polo Shirt">
    <input type="hidden" name="currency_code" value="GBP">
    <input type="hidden" name="amount" value="20.00">
    <input type="hidden" name="weight" value="0.18">
    <input type="hidden" name="weight_unit" value="kgs">
    <input type="hidden" name="quantity" value="1">
    <input type="hidden" name="undefined_quantity" value="1">
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="cn" value="Special Instructions">
    <input type="hidden" name="no_note" value="0">
    <input type="hidden" name="return" >
<input type="hidden" name="on0" value="Colour">



    <!-- Combo Box combo_30 -->

    <!--Preamble-->
    <select name="os0" size="1" style="position:absolute; left:8px; top:8px; /*Tag Style*/" __AddCode="here">
        <option value="Black" __AddCode="here">Black</option>
        <option value="White" __AddCode="here">White</option>
    </select>
    <!--Postamble-->


    <!-- Button btn_29 -->

    <!--Preamble-->
    <div style="position:absolute;left:75px;top:2px;width:116px;height:28px;"><button type="submit" id="btn_29" class="Button4" style="width:116px;height:28px;"><span>Buy&nbsp;Now</span></button></div>
    <!--Postamble-->
    </form>
    <!--Postamble-->
<!--MainDivEnd-->
</div>

カートに入れる:

<form id="form_36" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_self" style="margin:0;position:absolute;left:647px;top:957px;width:271px;height:44px; /*MainDivStyle*/" __AddCode="here">
<!--MainDivStart-->
<input type="hidden" name="bn" value="Serif.WebPlus">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="info@mysite.com">
<input type="hidden" name="item_name" value="Polo Shirt">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="amount" value="20.00">
<input type="hidden" name="weight" value="0.18">
<input type="hidden" name="weight_unit" value="kgs">
<input type="hidden" name="add" value="1">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="on0" value="Colour">


<!-- Combo Box combo_31 -->

<!--Preamble-->
<select name="os0" size="1" style="position:absolute; left:8px; top:8px; /*Tag Style*/" __AddCode="here">
    <option value="Black" __AddCode="here">Black</option>
    <option value="White" __AddCode="here">White</option>
</select>
<!--Postamble-->


<!-- Button btn_24 -->

<!--Preamble-->
<div style="position:absolute;left:75px;top:0px;width:188px;height:36px;"><button type="submit" id="btn_24" class="Button5" style="width:188px;height:36px;"><span>Add&nbsp;to&nbsp;Cart</span></button></div>
<!--Postamble-->
</form>

うまくいけば、写真は私がやりたいことへのより多くの洞察を与えるでしょう.

http://img849.imageshack.us/img849/3108/buttonvb.jpg

4

1 に答える 1

1

私が見ることができるように、フィールドは両方のフォームで似ているので、最初のフォームのみを保持し、2 番目のフォームを削除し、最初のフォームに両方のボタンを配置し、javascriptコマンドを切り替えるために使用することをお勧めします。

最初のフォームの変更:

別の非表示フィールドを追加 (カート オプションに必要)

<input type="hidden" name="add" value="1">

両方のボタンにonclickイベントを追加する

<button type="submit" id="btn_29" class="Button4" style="width:116px;height:28px;" onclick="setCMD('_xclick');"><span>Buy&nbsp;Now</span></button>
<button type="submit" id="btn_24" class="Button5" style="width:188px;height:36px;" onclick="setCMD('_cart');"><span>Add&nbsp;to&nbsp;Cart</span></

Javascript 関数:

<script type="text/javascript">
function setCMD(cmd) {
    form = document.getElementById("form_35");
    form.cmd.value = cmd; 
}   
</script>

お役に立てれば!

于 2013-04-23T22:29:05.207 に答える