Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing hidden with hyperlink

Status
Not open for further replies.

flnMichael

Programmer
Nov 13, 2003
96
US
I have a simple question, at least I think :cool:. I have a start page consisting of all hyperlinks. I also have a couple hidden variables within form tags that I need to pass through as sessions to the next pages, but unless I have a button to pass them, they don't go through. What am I doing wrong? Any help would be appreciated.

Thanks
 
If you need them as sessions, place them as sessions, and not in hidden form fields.

You should also consider consulting in the appropriate forum for the server side language you are using.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Here's the HTML portion
Code:
<form method='POST' id=form1 name=form1>

 <tr><td><a href=Programs_Guest.asp?factory=Fact1>Page 1</a></td></tr>
 <tr><td><a href=Programs_Guest.asp?factory=Fact2>Page 2</a></td></tr>

 <input type=hidden name=strYear value=<%Response.write Generic_TimeFormat(1, Now())%>>
 <input type=hidden name=strMonth value=<%Response.write Generic_TimeFormat(2, Now())%>>

Here's the function to get the month and year
Code:
function Generic_TimeFormat(num, strNow)
  Dim strTimeNow
  Dim strMonth
  Dim strYear

  strTimeNow = strNow
  strMonth = Month(strTimeNow)
  strYear = Year(strTimeNow)

  if num = 1 then
    Generic_TimeFormat = strYear

  else
    Generic_TimeFormat = strMonth
  end if

End Function

Now, when I get to any one of the second pages, I place this code at the top and get nothing
Code:
  session("strMonth") = Request("strMonth")
  session("strYear") = Request("strYear")
  Response.Write(session("strYear"))

I've done variations of a couple things, but still nothing. I get the right values in the hidden fields on the first page, they just don't transfer
 
This has nothing to do with the html portion.

Yo should consider addressing the session issue, in the ASP forum as this is what you are using to register the sessions.

ASP forum here: Forum333
ASP.NET forum here: Forum855

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I understand, but why, then, does it work when I use a button instead of a link to get to the next page? The session is working fine for another page where the transition is soley a submit button.
 
If you are talking about the hidden inputs its because the hidden inputs are form objects that require the form to be submitted for their contents to be sent. Links dont't submit form data, they just send the browser somewhere else.

You could explicitly add the values for the hidden fields to the URL link as you did with the factory variable:

Code:
<a href=Programs_Guest.asp?factory=Fact1&strYear=Response.write Generic_TimeFormat(1, Now())>



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Now I get it, thanks!

Now, I found another way to get it in a session variable:
Code:
function Generic_TimeFormat(num, strNow)
  Dim strTimeNow
  Dim strMonth
  Dim strYear

  strTimeNow = strNow
  strMonth = Month(strTimeNow)
  strYear = Year(strTimeNow)

  if num = 1 then
    Generic_TimeFormat = strYear
    session("strYear") = strYear
  else
    Generic_TimeFormat = strMonth
    session("strMonth") = strMonth
  end if

End Function

In the initial call, just set it to the session as well. I tell ya, the little things make the biggest difference.

Thanks for the help!
Mike
 
You're welcome. Glad I Could help.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top