Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2004, 04:12 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default not able to write check box output into table

i m not able to write checkbox out put into table filed every
thing is correct pls hel me my code as under

---------------------------
it is add ring.asp
---------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% listing_date=now()%>
<html>
<head>
</script>
<Script language="JavaScript">
function checkData(){
  if (document.addring.name.value == "" ||document.addring.name.value=="0") {
  alert("Please Enter a ring name")
  document.addring.name.focus()
  return false}
  }
</Script>

<title>Ring Addition Module</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body>
<p align="center"><img src="../images/mainheading.jpg" width="500" height="50">
</p>
<p><img src="../images/subheading.gif" width="800" height="30"></p>
<form action="./save_ring.asp" method="post" name="addring" id="addring" onsubmit="return checkData()">
  <table width="355" height="275" border="0">

    <tr>
      <td width="84"><b>Ring
        Name </b>&nbsp;</td>
      <td width="261"><input name="ring_name" type="text" size="20"></td>
    </tr>
    <tr>
      <td><b>Description</b></td>
      <td><textarea name="desc" id="textarea"></textarea></td>
    </tr>
    <tr>
      <td width="84" height="37"><p><b>Size(s) W:</b></p>


<td>
5<input name="chk1" type="checkbox" value="5">
5.5<input name="s2" type="checkbox" value="5.5">
6<input name="s3" type="checkbox" value="6">
6.5<input name="s4" type="checkbox" value="6.5">
7<input name="s5" type="checkbox" value="7">
7.5<input name="s6" type="checkbox" value="7.5">
8<input name="s7" type="checkbox" value="8">
8.5<input name="s8" type="checkbox" value="8.5">
9<input name="s9" type="checkbox" value="9">
9.5<input name="s10" type="checkbox" value="9.5">








</td>

    </tr>
    <tr>
      <td><b>Price</b></td>
     <td><input name="price" size="10" type="text"></td>
    </tr>
    <tr>
      <td><b>Karat</b></td>
      <td><input type="text" name="karat"></td>
    </tr>

    <tr>
      <td><b>Opening Qty</b></td>
      <td><input name="opqty" type="text" size="10"></td>
      </tr>
      <td><b>Listing Date</b></td>
      <td><input name="listing_date" type="text" value="<% = listing_date%>" ></td><tr></tr>

     <td><input name="Submit" type="submit" style="BACKGROUND-COLOR: #98BADC; BORDER-BOTTOM-COLOR: #69f; BORDER-BOTTOM-STYLE: outset; BORDER-LEFT-COLOR: #69a; BORDER-LEFT-STYLE: outset; BORDER-RIGHT-COLOR: #69f; BORDER-RIGHT-STYLE: outset; BORDER-TOP-COLOR: #69f; BORDER-TOP-STYLE: outset; COLOR: #fff; FONT-WEIGHT: bold" value="Add"></td>
  </table>

  <table width="453" border="0">
    <tr>
      <td>
        <%if request("check")="1" then%>
        <strong> *Ring Name exist Choose different name!</strong>
        <%elseif request("check")="2" then%>
        Successfully Added to Database
        <%
        else
        end if%>
        </td>

    </tr>
  </table>

  </form>
</body>
</html>
</head>
----------------------------
and this is save ring .asp which will run after add button


<%if session("granted") = false then
        response.redirect("unauth.htm")
else
'on error resume next
dim rs
ring_name=request.Form("ring_name")
set rs = server.CreateObject("Adodb.Recordset")
rs.open ("Select * from tblRings where name = '" & ring_name & "'"), conn,1,3
if rs.eof<>true and rs.bof<>true then
response.Redirect("add_ring.asp?check=1")
rs.close
set rs=nothing
else
dim objRS
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.open "tblRings", conn, adOpenForwardOnly, adLockOptimistic, adCmdTable
objRS.AddNew
objRS("name")=request.Form("ring_name")
objRS("desc")=request.Form("desc")
if request("chk1") = true then
objRS("size1")=request.Form("chk1")
end if
if request.Form("s2") = "on" then
objRS("size2")=request.Form("s2")
end if
if request.Form("s3") = "on" then
objRS("size3")=request.Form("s3")
end if
if request.Form("s4") = "on" then
objRS("size4")=request.Form("s4")
end if
if request.Form("s5") = "on" then
objRS("size5")=request.Form("s5")
end if
if request.Form("s6") = "on" then
objRS("size6")=request.Form("s6")
end if
if request.Form("s7") = "on" then
objRS("size7")=request.Form("s7")
end if
if request.Form("s8") = "on" then
objRS("size8")=request.Form("s8")
end if
if request.Form("s9") = "on" then
objRS("size9")=request.Form("s9")
end if
if request.Form("s10") = "on" then
objRS("size10")=request.Form("s10")
end if


objRS("listing_date")=request.Form("listing_date")
objRS("price")=request.Form("price")
objRS("qty")=request.Form("opqty")
objRS.update
objRS.close
set objRS=nothing
'response.Redirect("saveimage.asp")
response.Redirect("add_ring.asp?check=2")
end if
conn.close
end if%>

pls help me whats wrong and if u know the better solution pls teach me
thanks


 
Old June 7th, 2004, 04:53 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

 If u create checkbox as :
 <input name="s9" type="checkbox" value="9.5">
 then

if this check box is checked, u will get value as 9.5 else nothing.

You can check like this

if request.Form("s2") = "5.5" then
objRS("size2")=request.Form("s2")
end if

If u do not specify value while creating textbox, then u will get

request.Form("s2") = "on"


Om Prakash
 
Old June 7th, 2004, 04:55 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Small Correction in my statement below:

If u do not specify value while creating checkbox, then u will get

request.Form("s2") = "on"



Om Prakash
 
Old June 7th, 2004, 05:14 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

thanks OM u know the better way to write above code if yes please tell me

thanks again

 
Old June 7th, 2004, 06:46 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

change the code which creates text box as follows:

  <%
  ctr = 1
  for x = 5 to 9.5 step 0.5
  %>
  <input name="s<%=ctr%>" type="checkbox" value="<%=x%>"><%=x%>

  <%
  ctr = ctr + 1
  next
  %>

Change the code for recordset as follows:

<%
  ctr = 1
  for x = 5 to 9.5 step 0.5
    if trim(Request.Form("s" & ctr)) = trim(x) then
    Response.Write "Checkbox : (" & x & ")" & ctr & ": Yes <br>"
        'Update recordset value here.....
        objRS("size" & ctr)= request.Form("s" & ctr)
    else
    Response.Write "Checkbox : (" & x & ")" & ctr & ": No <br>"
    end if
     ctr = ctr + 1
  next
%>

Hope this helps....

Om Prakash
 
Old June 7th, 2004, 11:40 PM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

gr8 technique thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write T-SQL to retrieve the required Output anilkumar.dwivedi SQL Language 3 June 26th, 2008 12:37 AM
how to write output to an external file pigtail Javascript 2 April 30th, 2004 09:34 AM
How to output Response.write to certain location alyeng2000 ASP.NET 1.0 and 1.1 Basics 3 December 9th, 2003 10:03 AM
How to write output for both search and post arg mqnguyen Classic ASP Basics 2 July 29th, 2003 03:11 PM
how to index output data using Response.write mqnguyen Classic ASP Basics 2 July 15th, 2003 11:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.