Problem passing selected value to another page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmash
    New Member
    • Oct 2007
    • 6

    Problem passing selected value to another page

    Hello,

    The requirement is to display rows of data on a classic ASP page for rows in a recordset. On each row we have a link at the end to show detailed information about the selected row. A snapshot of the code is as follows: Please do not mind the html tags.

    Code:
    <table>
    	<th>Ticket number</th>
    	<th>Opened on</th>			
                     <th>Priority</th>
    	 <th>Description</th>
    	 <th>&nbsp;</th>
    <%
    	Set rs = rs.NextRecordSet()
    	
    	do while not rs.EOF
    			
    %>	
    		
    <tr><td nowrap>
    <b>
    <%=rs("CallID")%>
    </b></td>
    <td><%=rs("DateEntered")%></td>  
    <td align="center" nowrap><%=rs("PriorityID")%></td>
    <td width="50%"><%=rs("Subject")%></td>
    <td valign="bottom" nowrap><a href="viewticket.asp?callid=<%=rs("CallID")%>">View detail <img border=0 src="/support/images/right.gif"></a></td>
    </tr>
    <%
       rs.MoveNext
       Loop
    %>
    </table>
    The above code displays the call id in the URL but the requirement is not display the callid in the URL - possibly by using hidden fields for each row. I am unable to pass the selected value (in this case a callid) to another ASP page.

    Any advise help will be appreciated.

    Thanks,
    jmash
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    jmash,

    if I wanted to use a hidden input I would do something like this:
    [code=html]<form name="form1" action="viewtic ket.asp" method="post">< input type="hidden" name="callid"></form>
    ...
    <a onClick="docume nt.all.form1.ca llid.value='<%= rs("callid")%>' ; document.all.fo rm1.submit()">V iew detail <img border=0 src="/support/images/right.gif"></a>
    [/code]There are probably easier ways to do this, but you are entering javascript territory and I am not welcome there.

    Jared

    Comment

    • jmash
      New Member
      • Oct 2007
      • 6

      #3
      Hi Jared,

      Thanks for your comments. I have simplified the code to the following:

      Code:
      PassValue.asp
      <%@ language="VBScript"%>
      <html>
      <HEAD>
      <script language="javascript">
      <!--
      function setval(id)
      {
      	alert("Testing");	
      	document.all('selectedvalue').value=id;
      	alert(document.all('selectedvalue').value);
      	return false;
      }
      //-->
      </script>
      </HEAD>
      
      <body>
      <form action="TestSession.asp" method="post" name="ViewDetail" ID="ViewDetail">
      	<!--<a href="TestSession.asp" onclick="<%session("callid")="100"%>">Test</a>-->
      	<input type="hidden" name="selectedvalue" id="selectedvalue" value="">
      	<a href="TestSession.asp" onclick="setval(100);ViewDetail.submit()">Test</a>
      </form>
      </body>
      </html>
      The above code works fine.

      Now I want to check the value of hidden field selectedvalue within another page:

      Code:
      TestSession.asp
      <%@ Language="VBScript" %>
      <html>
      <head>
      </head>
      <body>
      <form action="listopentickets.asp" method="post" name="formviewdetail" ID="formviewdetail">
      Test ticketid 
      <br>
      <%=Request.Form.Item("selectedvalue")%>
      </form>
      </body>
      </html>
      
      But the above code does not display the hidden field value. Any ideas? Sorry it looks so simple but still it does not work.
      
      Many thanks in advance,
      jmash
      
      [QUOTE=jhardman]jmash,
      
      if I wanted to use a hidden input I would do something like this:
      [code=html]<form name="form1" action="viewticket.asp" method="post"><input type="hidden" name="callid"></form>
      ...
      <a onClick="document.all.form1.callid.value='<%=rs("callid")%>'; document.all.form1.submit()">View detail <img border=0 src="/support/images/right.gif"></a>
      [/QUOTE]
      Originally posted by jhardman
      There are probably easier ways to do this, but you are entering javascript territory and I am not welcome there.

      Jared

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        jmash,

        try: [code=asp]<%=Request("sel ectedvalue")%>[/code] Sometimes I list everything sent with the following code, just to make sure my stuff was sent and received by the next page:
        [code=asp]dim x
        response.write "<b>Form inputs:</b><br>"
        for each x in request.form
        response.write x & ": " & request.form(x) & "<br>" & vbNewLine
        next

        response.write "<b>Queryst ring inputs:</b><br>"
        for each x in request.queryst ring
        response.write x & ": " & request.queryst ring(x) & "<br>" & vbNewLine
        next

        response.write "<b>Cookies :</b><br>"
        for each x in request.cookies
        response.write x & ": " & request.cookies (x) & "<br>" & vbNewLine
        next

        response.write "<b>Server Variables:</b><br>"
        for each x in request.serverV ariables
        response.write x & ": " & request.serverV ariables(x) & "<br>" & vbNewLine
        next[/code]Of course you probably would know if you had sent a cookie, so that part is probably not very useful. The server variables have some useful info, but probably not for your current project. But I think it's a good idea to print out the form and querystring inputs like this for troubleshooting .

        Jared

        Comment

        Working...