c# - Having Issues with using VISIBLE. My Javascript doesnt seem to be handling the event when the check box is clicked -
all of hidden fields have id's. , in javascript in trying set visible false true on payment selection. cash payment should display address sent to. credit card payment comes text boxes , labels in order process payment online. when run script wont appear checkbox selection. assigned onclick event , still doesnt work. suggestions?
<%@ page title="" language="c#" masterpagefile="~/site.master" autoeventwireup="true" codefile="shoppingcart.aspx.cs" inherits="shoppingcart" %> <asp:content id="content1" contentplaceholderid="headcontent" runat="server"> <head> <script type="text/javascript"> function paymentfunction() { if (document.getelementbyid("rbcash").checked) { document.getelementbyid("lbcash").visible = true; document.getelementbyid("lbcash2").visible = true; document.getelementbyid("lbcash3").visible = true; document.getelementbyid("lbcash4").visible = true; } else { if(document.getelementbyid("rbcreditcard").checked) { document.getelementbyid("lbcard").visible = true; document.getelementbyid("lbcardnum").visible = true; document.getelementbyid("lbcvv").visible = true; document.getelementbyid("lbexp").visible = true; document.getelementbyid("ddlcard").visible = true; document.getelementbyid("tbcnum").visible = true; document.getelementbyid("tbcvvnum").visible = true; document.getelementbyid("tbexp").visible = true; } } } </script> <style type="text/css"> .style1 { width: 100%; } .style2 { width: 100%; } .style3 { width: 130px; } </style> </head> </asp:content> <asp:content id="content2" contentplaceholderid="maincontent" runat="server"> <table class="style2"> <tr> <td class="style3"> payment type:</td> <td> <asp:checkbox id="rbcash" runat="server" onclick="paymentfunction()" text="cash" clientidmode="static"/> <asp:checkbox id="rbcreditcard" runat="server" onclick="paymentfunction()" text="credit card" /> </td> </tr> <tr> <td class="style3"> </td> <td> <asp:label id="lbcash" runat="server" forecolor="black" text="please send payment to:" visible="false" clientidmode="static"></asp:label> </td> </tr> <tr> <td class="style3"> </td> <td> <asp:label id="lbcash2" runat="server" forecolor="black" text="wild style shoes" visible="false" clientidmode="static"></asp:label> </td> </tr> <tr> <td class="style3"> </td> <td> <asp:label id="lbcash3" runat="server" forecolor="black" text="1808 west avenue" visible="false" clientidmode="static"></asp:label> </td> </tr> <tr> <td class="style3"> </td> <td> <asp:label id="lbcash4" runat="server" forecolor="black" text="chicago, il 88947" visible="false" clientidmode="static"></asp:label> </td> </tr> <tr> <td class="style3"> <asp:label id="lbcard" runat="server" text="card type" visible="false"></asp:label> </td> <td> <asp:dropdownlist id="ddlcard" runat="server" visible="false"> <asp:listitem>select card</asp:listitem> <asp:listitem>visa</asp:listitem> <asp:listitem>discover</asp:listitem> <asp:listitem>mastercard</asp:listitem> <asp:listitem>american express</asp:listitem> </asp:dropdownlist> </td> </tr> <tr> <td class="style3"> <asp:label id="lbcardnum" runat="server" text="card number:" visible="false"></asp:label> </td> <td> <asp:textbox id="tbcnum" runat="server" visible="false" width="200px"></asp:textbox> </td> </tr> <tr> <td class="style3"> <asp:label id="lbcvv" runat="server" text="cvv number" visible="false"></asp:label> </td> <td> <asp:textbox id="tbcvvnum" runat="server" visible="false" width="58px"></asp:textbox> </td> </tr> <tr> <td class="style3"> <asp:label id="lbexp" runat="server" text="expiration date" visible="false"></asp:label> </td> <td> <asp:textbox id="tbexp" runat="server" visible="false"></asp:textbox> </td> </tr> <tr> <td class="style3"> </td> <td> <asp:button id="button1" runat="server" text="submit payment" visible="false" /> </td> </tr> </table> <p> </p> <p> </p> <p> thank shopping us:<br /> </p> <p> </p> <p> </p> <p> </p> <p> </p> </asp:content>
if set visible = false on server side doing, server not render control.
you want following:
<asp:label id="lbcash" runat="server" forecolor="black" text="please send payment to:" style="visibility:hidden" clientidmode="static"></asp:label>
then in javascript this:
document.getelementbyid('lbcash').style.visibility = 'visible';
Comments
Post a Comment