Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 November 6th, 2006, 07:41 AM
Authorized User
 
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Assigning value from variable

I have passed value from Dropdown ListBox of a form to an ASP page using POST method. In that I have stored the value to a variable. Further I want to assign the value to one some control which I want to send the same to another ASP page using the post method.

When I tried this it is showing the variable name in the final ASP page not the value.

please help.

Thanks in advance.
 
Old November 6th, 2006, 11:47 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please show your relevant code.


Woody Z http://www.learntoprogramnow.com
 
Old November 7th, 2006, 02:37 AM
Authorized User
 
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Coding in Issue.Asp
Missing code for enabling the Category List Box
------------------------------------------------
<FORM Method="POST" Action="issuetest.asp" Name="frmIssue">
<P>Category
<INPUT id=radio1 type=radio name=cat value="CA" checked onClick="showCat()">All
<INPUT type=radio name=cat value="CS" onClick="showCat()">Specific<Br>
Select Category
<SELECT id=catlist style="WIDTH: 164px" name=catlist disabled>
<OPTION selected>Stationery</OPTION>
<OPTION>Sanitary</OPTION>
<OPTION>Perishable-I</OPTION>
<OPTION>Perishable-II</OPTION>
</SELECT></P>
<INPUT TYPE="Submit" Value="Go">
</FORM>

Some Part of Coding in Issuetest.Asp
Missing code for enabling the Item List Box
--------------------------------------------
<%
Dim objCon
Dim rsItem
Dim Catlist
Dim cat

cat = Request.Form("cat")
catlist = Request.Form("catlist")
%>
<FORM Method="POST" Action="showissue.asp" Name="frmIssue">
<INPUT TYPE="Hidden" Name="cat" Value=cat>
<INPUT TYPE="Hidden" Name="catlist" value=catlist>
<%
Set objCon=Server.CreateObject("ADODB.Connection")
objcon.open "stores"

Set rsItem=Server.CreateObject("ADODB.Recordset")
If cat="CA" Then
    rsItem.open "Select Icode,Name From Item Order By Name",objCon
Else
    rsItem.Open "Select Icode,Name From Item where Category='"& catlist &"' Order by Name",objCon
End if
%>
<SELECT style="WIDTH: 281px" name="itemlist" SIZE="1" disabled>
<%
    Do While Not rsItem.EOF
        Response.Write "<OPTION VALUE="&rsItem("Icode")&">"&rsItem("Name")&"</OPTION>"
        rsItem.MoveNext
    Loop

    rsItem.Close
    Set rsItem=nothing
%>
</SELECT></P>
</FORM>

Some Part of Coding in showissue.Asp
<%
optCat = Request.Form("cat")
strCat = Request.Form("catlist")

Response.Write optcat&"<Br>"&strcat&"<br>"
%>

The output of the above code is
cat
catlist

But I want the original value stored in cat and catlist
e.g:
CS
Stationery

Thanks in advance
 
Old November 7th, 2006, 11:57 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah. An easy to miss little problem.

Your code:
Code:
<INPUT TYPE="Hidden" Name="cat" Value=cat>
<INPUT TYPE="Hidden" Name="catlist" value=catlist>
Needs to look more like this
Code:
<INPUT TYPE="Hidden" Name="cat" Value=<%=cat%>>
<INPUT TYPE="Hidden" Name="catlist" value=<%=catlist%>>
I am sure you see the problem now. You need to use the value from the local variables as you build the HTML. This needs to be enclosed in script tags as you can see - otherwise your HTML just uses the literal string (such as cat and catlist) rather than the variables (and thus the values) those variables hold.

Have fun,
Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
Assigning variable value from a radio button cybersnac VB How-To 0 February 14th, 2007 03:57 PM
Assigning a @@ROWCOUNT to a variable ioates SQL Server DTS 2 January 9th, 2004 04:16 AM
Help with assigning a variable from a binding dfranczak ADO.NET 0 July 17th, 2003 01:50 PM





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