Skip to main content
Participating Frequently
October 5, 2010
Question

Session Variable not being transferred to Web Page.

  • October 5, 2010
  • 3 replies
  • 658 views

Hi,

If someone could get me out of this muddle I'll be verry happy......

I have a javascript function which is being executed by the onChange() event from a dynamic dropdown list. i.e.  <select name="lsNames" id="lsNames" onChange="getIndex();>

function getIndex()
  {
   var x = document.main_details.lsNames.selectedIndex;
var federal_id = document.main_details.lsNames.options.value;
alert(federal_id );
Session["federal_id"]=federal_id;
return (federal_id);
  }

All the above works fine and federal_id is what it should be, however when I call the response redirect from an on submit button the session variable is blank am I missing something?

Response.Redirect "http://websiteaddress/update_system_manager.asp?federal_id=" & Session("federal_id")

The session variable 'federal_id' is declared in both web pages, it seems the javascript code is being transferred to the session variable.

Thanks in advance.

Joan.

This topic has been closed for replies.

3 replies

Participating Frequently
October 6, 2010

Hi again,

I can't believe I have just found a solution...........

document.getElementById('federal_id').value  = federal_id;

Now I am sure I'd already tried this to update the text fields, however what I think I might of done is used double quotes around the ID Element and not single quotes, why couldn't it of given me a syntax error? would of saved me days of frustration !!!!

Joan.

Participating Frequently
October 6, 2010

ok so I thought I'd found the solution but I can only update one of the fields on the form because I am only bring one value back to the form.

How do I get the dynamic list to give me all the values that I display in it? If I include all the displayed values then that is what the value turns out to be and that isnt very good because I'd have to split it all up to repopulate the fields.

I bring back only one value in the menu list "value=

"<%=(rsNames.Fields.Item("federal_id").Value)%>"

but show several fields so the user knows they are picking the right one !!

"<%=(rsNames.Fields.Item("last_name").Value &" , "& rsNames.Fields.Item("first_name").Value & ", ( " & rsNames.Fields.Item("known_as").Value & " ) , " & rsNames.Fields.Item("federal_id").Value & " , " & rsNames.Fields.Item("extn").Value & " , "& rsNames.Fields.Item("work_function").Value & " , " & rsNames.Fields.Item("building").Value & " - " & rsNames.Fields.Item("room").Value)%>"

I could call a vbscript function to requery the database with the value of the menu list and repopulate the rest of the fields on the form, but I can't call a vbscript function from javascript, so I'm back to square one again!!!!

Please help me someone ????

Joan.

Participating Frequently
October 6, 2010

Solved using a cookie as suggested. Thanks.

document.cookie = "federal_id=" + federal_id;
window.location='http://webserver/Nets/update_system_manager.asp?federal_id=' + federal_id

then picked up the cookie on the person detail page to requery the database and add the additional data.

Thanks again for the pointers.

Participating Frequently
October 6, 2010

Thanks for your response.  God I wish I knew what I was trying to achieve !! I'm pretty ok with the database / connectivity side of things, but the Dreamweaver / javascript and vbscript is new and self taught (always the worst I know !), so let me try and explain.

I've been given a crappy legacy database from MSAccess that holds lots of network details attached to redundant person details, although I have managed to get the data from the access table and into a nice new table in our production database, the data needs updating.  My theory was to show the 'crappy' record, but provide a drop down list of upto date personnel that they can select and update the current (crappy) record with.

So once they have logged into the first web page, they are shown a full list of the current rows in the table, the user can then select an individual row in the table and an on click of the row, be presented will all the crappy data in the row on a main detail asp.  Hope your with me so far :-/

This main detail asp loads containing the text fields from the data in the table, I've added a dynamic drop down list of current upto date person information. I want the user to be able to select from the drop down list to either immediately update the person part of the form fields with the new person details, or (as the main detail asp stands at the moment), click a 'replace' button to update the person part of the form, then with new details loaded, click on an update button at the bottom of the web page.

I've been through several versions of what I'm trying to achive, but ideally, selecting from the list of upto date person details and updating the form fields from an onChange() event  would be the best solution, but I was unable to get the form to update with an onChange() before the update button on the web was selected, so my only route was to capture the federal_id and send it to another web page, query another table and show the new person details there with an add button to accept them or a cancel button to return to the detail page again.

Participating Frequently
October 5, 2010

It's really hard to tell what you are trying to accomplish with just the small snippets of code you provided. I don't know why you would call a response.redirect from a submit button. I would think there would be a better way.

AFAIK, JS sessions do not survive between pages. You would need to set a cookie, or use AJAX to set a server session value.