Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    radio button problem

    i have 3 radio button.
    1st radio button is checked.
    when i clik at 2nd and 3rd radion button it get me a popup page,
    but the radio button not checked.
    how can i do to make when i clik at 2nd and 3rd radio button get me a popup page and in same time checked that radio buton???

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    The radio button should be checked when you click it. Maybe you're returning false to the onclick handler? Can you post your code?

  • #3
    New Coder
    Join Date
    May 2005
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    my cording.

    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/pos_conn.asp" -->
    <%

    tblno = request.form("tblno")
    response.cookies("tblno") = tblno
    billno = request.form("billno")
    response.cookies("billno") = billno

    %>

    <%
    Dim Recordsetbill
    Dim Recordsetbill_numRows

    Set Recordsetbill = Server.CreateObject("ADODB.Recordset")
    Recordsetbill.ActiveConnection = MM_pos_conn_STRING
    Recordsetbill.Source = "SELECT * FROM restaurant.bill"
    Recordsetbill.CursorType = 0
    Recordsetbill.CursorLocation = 2
    Recordsetbill.LockType = 1
    Recordsetbill.Open()

    Recordsetbill_numRows = 0
    %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link href="pos.css" rel="stylesheet" type="text/css">
    <title>Receipt Form</title>

    <script language= "JavaScript">

    function update(){
    var a = receipt.tblno.value;
    if ( a != "" ) {
    receipt.action="updatecc.asp";
    receipt.submit();
    }
    }

    function popup11(a,b,c,d,e,f,g,h,j) {

    var nW = window.open("", "popup", "resizable=no,scrollbars=yes,width=300,height=300");
    nW.location.href = "search2.asp?field="+ a +"&field2=" + b+"&field3=" + c+"&field4=" + d+"&field5=" + e+"&field6="+f +"&field7="+g +"&field8="+h +"&field9="+j;

    nW = null;

    }
    function popup111(a,b,c,d,e,f,g,h,j) {

    var nW = window.open("", "popup", "resizable=no,scrollbars=yes,width=300,height=300");
    nW.location.href = "searchbillno.asp?field="+ a +"&field2=" + b+"&field3=" + c+"&field4=" + d+"&field5=" + e+"&field6="+f +"&field7="+g +"&field8="+h +"&field9="+j;

    nW = null;

    }
    function balance2(){


    var a = receipt.cashreceive.value;
    var b = receipt.total_amount.value;

    if ((a != "") && (b != "")) {
    var balance = a - b;

    receipt.bal.value = balance.toFixed(2);
    }

    }

    function GoBalance(){
    a = receipt.tblno.value;
    b = receipt.cashreceive.value;

    if ((a != "" ) && ( b != "" )) {
    receipt.action = "balance1.asp";
    receipt.submit();
    }
    }





    function table(){

    var a = receipt.tblno.value;

    receipt.chktbl.value = "change";
    receipt.action = "receiptform.asp";
    receipt.billno.value="";
    receipt.receipt.value="";
    receipt.submit();
    alert(a);

    }




    </script>
    </head>


    <form name="receipt" method="post">
    <input type = hidden name = "chktbl" value = "<%=request.cookies("changetbl")%>" />
    <input type = hidden name = "bal" />

    <body onload="" background="color.gif">
    <p>
    <!--################################connect to database################# -->
    <%




    if request.form("tblno") <> "" or request.cookies("tblno") <> "" then
    if request.form("tblno") <> "" then
    tableno = request.form("tblno")
    end if

    set conS=server.CreateObject("ADODB.Connection")
    set rsS=server.CreateObject("ADODB.Recordset")
    strSQLS= "SELECT * FROM bill"
    rsS.CursorType = 2
    rsS.LockType = 3
    conS.open "Driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;database=restaurant"
    rsS.open strSQLS,conS

    SQL_1 = "Select * from bill WHERE tblno ='" & tableno & "'"
    set b = conS.Execute(SQL_1)

    '############################# matching #####################

    If b.BOF = true AND tableno <> "" THEN
    chk = "1"
    else
    chk = "0"
    end if
    '###################################################

    '############################dapat cari##############################
    if chk = 0 then
    set conS=server.CreateObject("ADODB.Connection")
    set rsS=server.CreateObject("ADODB.Recordset")
    strSQLS= "Select * from bill WHERE tblno ='" & tableno & "'"
    rsS.CursorType = 2
    rsS.LockType = 3
    conS.open "Driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;database=restaurant"
    rsS.open strSQLS,conS

    dim ttlamt

    tblno = ("tblno")
    date1 = rsS("date1")
    billno = rsS("billno")
    amt = rsS("amt")
    govtax = rsS("govtax")
    srvtax = rsS("srvtax")
    ttlamt = rsS("ttlamt")
    disc= rsS("disc")
    vouc= rsS("vouc")
    end if
    '##################################################
    end if





    %>

    </p>
    <table width="601" height="400" border="6" align="center" bordercolor="#006699" bgcolor="#DDF2F2">
    <tr>
    <td width="581" height="384">
    <table width="578" height="101" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr>
    <td width="139" height="24">Table Number</td>
    <td width="8">:</td>
    <td width="148"> <input name="tblno" type = "text" id = "tblno5" onBlur="table()" value="<%=tableno%>" maxlength="10" /></td>
    <td width="29"><img src="images1/search%5B3%5D.gif" width="16" height="16" onclick="popup11(['document.receipt.tblno'] , ['document.receipt.bill'],['document.receipt.date'],['document.receipt.amount'],['document.receipt.total_amount'],['document.receipt.item_disct'],['document.receipt.vouc_disc'],['document.receipt.govtax'],['document.receipt.srvtax'])"/></td>
    <td width="41">&nbsp;</td>
    <td width="201">&nbsp;</td>
    </tr>
    <tr>
    <td height="24">Receipt Number</td>
    <td>:</td>
    <td> <input name = "receipt" type = "text" id = "ReceiptNo5" value = "<%=receipt%>" maxlength="12" readonly/></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="25">Bill Number</td>
    <td>:</td>
    <td><input name = "billno" type = "text" value = "<%=billno%>" id = "bill" maxlength="16" readonly/></td>
    <td><img src="images1/search%5B3%5D.gif" width="16" height="16" onclick="popup111(['document.receipt.tblno'] , ['document.receipt.bill'],['document.receipt.date'],['document.receipt.amount'],['document.receipt.total_amount'],['document.receipt.item_disct'],['document.receipt.vouc_disc'],['document.receipt.govtax'],['document.receipt.srvtax'])"/></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Date</td>
    <td>:</td>
    <td><input type = "text" name="date" value ="<%=date1%>" id ="date4" maxlength="10" readonly></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <table width="579" height="79" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr>
    <td width="187" height="26">Total(RM)</td>
    <td width="9">:</td>
    <td width="144"><input type = "text" name = "amount" value ="<%=amt%>" id = "amount5" maxlength="10" style="font-size: 10pt" readonly/>
    </td>
    <td width="252" colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td height="26">Item Disc(%)</td>
    <td>:</td>
    <td><input type = "text" name="item_disct" id = "item_disct" value ="<%=disc%>" maxlength="10" readonly /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td height="27">Voucher Disc(%)</td>
    <td>:</td>
    <td><input type = "text" name="vouc_disc" id = "vouc_disc" value ="<%=vouc%>" readonly maxlength="10" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <table width="579" height="200" border="0" cellpadding="1" cellspacing="0" align="center">
    <tr>
    <td width="179">Gov Tax(%)</td>
    <td width="8">:</td>
    <td width="144"> <input name="govtax" type = "text" id = "govtax" value ="<%=govtax%>"maxlength="10" readonly/>
    </td>
    <td width="240"><p>&nbsp;</p>
    <p>&nbsp;</p></td>
    </tr>
    <tr>
    <td>Service Tax(%) </td>
    <td>:</td>
    <td> <input name="srvtax" type = "text" id = "srvtax" value="<%=srvtax%>" maxlength="10" readonly/></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Total Amount (RM)</td>
    <td>:</td>
    <td><input type = "text" name="total_amount" id = "total_amount5" value ="<%=ttlamt%>" maxlength="10" readonly/></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="4"><table width="513" height="41" border="1" align="center">
    <tr>
    <td width="464" height="37"><div align="center">
    <table width="448" height="25" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr>
    <td width="136" ><div align="center">
    <input name="payterm" type="radio" id="cash" value="cash" onfocus="cash()"checked />

    Cash</div></td>

    <td width="189"><div align="center">

    <input name="payterm" type="radio" id="card" onclick="popup1()" value="card" />

    Credit Card </div></td>
    <td width="117"><div align="center">
    <input name="payterm" type="radio" id="term" onclick="popup2()" value="term" />
    Credit Term</div></td>
    </tr>
    </table>
    </div></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>Cash Received </td>
    <td>:</td>

    <td><input type = "text" name="cashreceive" id = "cashreceive" value ="<%=cashreceive%> " maxlength="10" onBlur="balance2()" /></td>

    <td><input type="submit" name="Submit" value=" Paid " onClick="GoBalance()">
    </td>
    </tr>
    <tr>
    <td height="39" colspan="4">

    <p align="right"> <img src="images/re-print.gif" width="34" height="34" border="0">&nbsp;</p>
    </td>
    </tr>
    </table></td>
    </tr>
    </table>
    <p>
    <!--#################################################################################-->
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </form>
    </html>

    <script language="JavaScript">
    function popup1(){
    receipt.submit();
    window.open("creditcard.asp", "creditcard", "resizable=no,scrollbars=yes,width=450,height=200");
    }

    function popup2(){
    receipt.submit();
    window.open("creditterm.asp", "creditcard", "resizable=no,scrollbars=yes,width=450,height=310");


    }
    </script>

    <%
    Recordsetbill.Close()
    Set Recordsetbill = Nothing

    %>

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    The reason the radio button was not checked is because it opens a popup and then submit the page to itself causing the page to be redisplayed. What do you want to happen when the radio button is checked, submit the page to the popup or just open the popup without submitting the page?

    If you want the former...

    Code:
    <input name="payterm" type="radio" id="card" onclick="popup(this.form, 'creditcard.asp', 450, 200)" value="card" />
    <input name="payterm" type="radio" id="term" onclick="popup(this.form, 'creditterm.asp', 450, 310)" value="term" />
    ...
    function popup(oFrm, actionPage, w, h){
      oFrm.action = actionPage;
      oFrm.target = "creditcard"
      var w = window.open("", oFrm.target, "resizable=no,scrollbars=yes,width="+w+",height="+h);
      w.focus();
      oFrm.submit();
    }
    You need to modify other functions to reset the form target to "_self" so that normal submit buttons will submit the page to current window.


    If you want the latter:
    Code:
    <input name="payterm" type="radio" id="card" onclick="popup('creditcard.asp', 450, 200)" value="card" />
    <input name="payterm" type="radio" id="term" onclick="popup('creditterm.asp', 450, 310)" value="term" />
    ...
    function popup(url, w, h){
      var w = window.open(url, "creditcard", "resizable=no,scrollbars=yes,width="+w+",height="+h);
      w.focus();
    }

    You need to reference the form correctly. You're only referencing it directly by name. Only IE tolerates that bad habit.
    You should reference it by using document.receipt or if the function is called by an HTML control (such as submit and normal buttons, radio buttons, comboboxes, text fields, and the like), you can pass this.form as parameter to the function, just like the way I did in my suggestion#1.

  • #5
    New Coder
    Join Date
    May 2005
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ok...

    the problem is clear..but get another problem come..
    i cannot save my data to database .??

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    "i cannot save my data to database .??"

    Do you think that gives us a clue to solve your problem?
    How would you encourage helpers to help you if you won't provide details of the problem?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •