Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    313

    Anyone please help with asp

    Can anyone please help me with this asp sample?
    I know that many of you are into php but I recall one of you helping me with asp before.

    I have a selection box where I can choose country, after I select the country a table is created with 3 columns from the database

    I then want to post the record from column 1 to a processform.asp "which works fine" this column is called companyname.

    Here is what I have

    <html>
    <body>

    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("/db/northwind.mdb"))

    set rs=Server.CreateObject("ADODB.recordset")
    sql="SELECT DISTINCT Country FROM Customers ORDER BY Country"
    rs.Open sql,conn

    country=request.form("country")

    %>

    <form method="post">
    Choose Country <select name="country">
    <% do until rs.EOF
    response.write("<option")
    if rs.fields("country")=country then
    response.write(" selected")
    end if
    response.write(">")
    response.write(rs.fields("Country"))
    rs.MoveNext
    loop
    rs.Close
    set rs=Nothing %>
    </select>
    <input type="submit" value="Show customers">
    </form>

    <%
    if country<>"" then
    sql="SELECT Companyname,Contactname,Country FROM Customers WHERE country='" & country & "'"
    set rs=Server.CreateObject("ADODB.Recordset")
    rs.Open sql,conn
    %>
    <table width="100%" cellspacing="0" cellpadding="2" border="1">
    <tr>
    <th>Companyname</th>
    <th>Contactname</th>
    <th>Country</th>
    </tr>
    <%
    do until rs.EOF
    response.write("<tr>")
    response.write("<td>" & rs.fields("companyname") & "</td>") \\I want to post this to the next page
    response.write("<td>" & rs.fields("contactname") & "</td>")
    response.write("<td>" & rs.fields("country") & "</td>")
    response.write("</tr>")
    rs.MoveNext
    loop
    rs.close
    conn.Close
    set rs=Nothing
    set conn=Nothing%>
    </table>
    <% end if %>

    </body>
    </html>

    If anyone can help with this it will be very much appreciated.

    Thanks Guys.

  2. #2
    Join Date
    Feb 2004
    Location
    Cardiff
    Posts
    78
    Im a little bit confused as to what you want to do so may have the worng end of the stick.

    If you want to send the value from this page to the next you could include it inside your form.

    <input type="text" value="<%=rs.fields("companyname")%>">

    You could also do

    <input type="hidden" value="<%=rs.fields("companyname")%>">

    If you wanted to pass a value but not display it to the user.

  3. #3
    Join Date
    Feb 2004
    Location
    Cardiff
    Posts
    78
    sorry that should be:

    <input type="text" name="a_name" value="<%=rs.fields("companyname")%>">

  4. #4
    Join Date
    Jul 2004
    Posts
    313
    Thanks Philo,

    It does not sem to work but I will keep trying, I appreciate your help.


  5. #5
    Join Date
    Feb 2004
    Location
    Cardiff
    Posts
    78
    Ensure that line is within your form tags

    Alternatively

    Have you tried session variables?

    Try Session("companyname") = rs.fields("companyname")

    Then you can return it on any future pages by doing

    Dim companyname
    companyname = Session("companyname")

    Have a look here for more info
    http://www.w3schools.com/asp/asp_sessions.asp

Similar Threads

  1. Check if allowed to update using ASP and Trueupdate
    By nickw in forum TrueUpdate 1.0
    Replies: 4
    Last Post: 06-20-2003, 01:13 PM
  2. ASP Web Get/Post
    By greenace in forum Setup Factory 6.0
    Replies: 9
    Last Post: 06-06-2003, 11:01 PM
  3. Submit to web ASP
    By kaylward in forum Setup Factory 6.0
    Replies: 1
    Last Post: 11-30-2002, 07:15 PM
  4. True Update from ASP
    By day10 in forum TrueUpdate 1.0
    Replies: 3
    Last Post: 08-08-2002, 03:07 PM

Posting Permissions

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