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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing variables

    I am working on a simple page that passes variables from check boxes on one page to another page. Forgive my lack of knowledge, I am a newbie. Is there a way to have the values that were passed, dynamically stack themselves? I am using the follwing code to show the values that were passed:

    <table align=center width="480">
    <tr>
    <!-- assign hidden field values -->
    <input type=hidden name=terracotta value="<%=terracotta%>">
    <input type=hidden name=chamois value="<%=chamois%>">
    <input type=hidden name=redwood value="<%=redwood%>">
    <input type=hidden name=jade value="<%=jade%>">
    </tr>
    <tr>
    <%=terracotta%>
    <%=chamois%><br>
    <%=redwood%><br>
    <%=jade%br><br>
    </tr>
    </table>

    This work, but if I only choose redwood on the first page it stays where it is with space for the first two values that weren't passed above it. Is it possible to have the values stack one on top of another even if there were values in between them?
    Any help will be greatly appreciated!

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    I would use the IF statement and the LEN statement bundled with a sub routine.

    Code:
    sub Write(TheVar, Space)
    If Space = 0 Then
    response.write(TheVar)
    Else
    response.write("<br>"&TheVar)
    End If
    End Sub
    
    If len(terracotta) > 0 Then
    Write terracotta, 0
    Prev = 1
    End If
    If Len(chamois) > 0 Then
    Write chamois, Prev
    End If
    If Len(redwood) > 0 Then
    Write redwood, Prev
    End If
    If Len(jade) > 0 Then
    Write jade, Prev
    End If
    Replace the below with that..
    Code:
    
    <%=terracotta%>
    <%=chamois%><br>
    <%=redwood%><br>
    <%=jade%>
    
    Last edited by Mhtml; 01-18-2003 at 04:04 AM.
    Omnis mico antequam dominus Spookster!

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for such a quick response.
    When I replace the code, with the sub routine and if...then statements, the code shows up on my asp page when I go to it. It isn't actually showing values. Am I doing something wrong?

    Here is my code:
    <--
    <% @LANGUAGE="VBSCRIPT" %>
    <% Option Explicit %>
    <%
    'COMMENTS
    '--START SET VARIABLES, SERVER-SIDE FUNCTIONS, REQUIRED PARAMETERS
    'Declare Variables
    Dim terracotta,chamois,redwood,jade

    'Get Form Variables
    terracotta = Request("terracotta")
    chamois = Request("chamois")
    redwood = Request("redwood")
    jade = Request("jade")
    '--START PRESENTATION
    %>
    <HTML>
    <HEAD>
    <TITLE>Title</TITLE>
    </HEAD>
    <BODY>
    <table align=center width="480">
    <tr>
    <!-- assign hidden field values -->
    <input type=hidden name=terracotta value="<%=terracotta%>">
    <input type=hidden name=chamois value="<%=chamois%>">
    <input type=hidden name=redwood value="<%=redwood%>"> <input type=hidden name=jade value="<%=jade%>">
    </tr>
    <tr>
    <font face=Arial, Helvetica, San Serif size=2><b>General Request Information</b><BR>

    sub Write(TheVar, Space)
    If Space = 0 Then
    response.write(TheVar)
    Else
    response.write("<br>"&TheVar)
    End If
    End Sub

    If len(terracotta) > 0 Then
    Write terracotta, 0
    Prev = 1
    End If
    If Len(chamois) > 0 Then
    Write chamois, Prev
    End If
    If Len(redwood) > 0 Then
    Write redwood, Prev
    End If
    If Len(jade) > 0 Then
    Write jade, Prev
    End If
    </tr>
    </table>
    </BODY>
    </HTML>

  • #4
    New Coder
    Join Date
    Jan 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Before the code that I listed above, would I use the script statement before the code or the function statement?

  • #5
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    I would think you would place the code here:
    chamois = Request("chamois")
    redwood = Request("redwood")
    jade = Request("jade")
    '--START PRESENTATION
    _HERE_
    %>
    <HTML>
    <HEAD>
    <TITLE>Title</TITLE>
    But I think you would change Write into a variable that will store the data.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm still confused... what do you mean by "dynamically stack themselves"?

    If you're only trying to display variables that have a value (i.e. someone checked the checkbox on the first page), you can do this:
    Code:
    terracotta = Request.Form("terracotta")
    If terracotta <> "" Then Response.Write(terracotta & "<br />" & vbCrLf)
    etc. Not sure if I would create a function for something as simple as Response.Write, though, Mhtml...

    Last edited by whammy; 01-20-2003 at 02:12 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    New Coder
    Join Date
    Jan 2003
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all the replies, like I said I am very new to all this and I am probably not using the correct terminology.

    whammy, what I mean by dynamically stack is: in the first portion of code I posted, if 2 check boxes were checked on the first page and I displayed the values on the second, and there were 2 boxes unchecked in between the two that were checked the spaces for the two unchecked were left between the 2 displayed values.

    What I am trying to accomplish is, if 2 boxes are checked, with boxes between them unchecked, that when I display the values on the second page the values will be displayed without any spaces between them for values that aren't displayed.


  •  

    Posting Permissions

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