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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with Storing Variables

Status
Not open for further replies.

Cranger

Programmer
Apr 4, 2001
54
US
Please remember I am still learning ASP and Not even sure I can do this.

I have a DB selection list. When I select something I call a the "onclick" function that then calls the same page. I pass along in the call string "intCompanyID=9" so I know which company was selected and I can repopulate the list. However, if input is already entered in other fields, when I come back, I loose all the data. Either I am not populating my session variables correctly, or they get reset when I call the page. So my question is 2 fold.

1. Can I call the page that I am currently on and pass field values that are field in through session variables?

2. When/how do I populate them.
 
I thought I should add why I am doing what I am doing incase there is another way to do it.

I Have 2 selection boxes. The second selection box is based on the results of the first box. (i.e. They select a company name in the first box, and then I populate the second with the values.) Without Recalling the Page, I don't know how to populate the second selection box.
 
Suppose you use: MyPage.asp?intCompanyID=9
In MyPage.asp you assign this to a variable:

dim nIntCompanyID
nIntCompanyID = request.querystring("IntCompanyID")

. . . .
A better approach.

I suppose your other fields are empty when you start your page? Put them in a <form method=post action=mypage.asp>
in your SELECT you must *submit* the form when a change occurs:
<select name=IntCompany onchange=&quot;submit()&quot;>
<option value=9>Number Nine
</select>


in MyPage.asp you can request all the form values:
dim cField1, cField2, nIntCompanyID
cField1 = request.form(&quot;field1&quot;)
cField2 = request.form(&quot;field2&quot;)
nIntCompanyID = request.form(&quot;IntCompanyID&quot;)


In order to get the values in the fields you do this:
response.write &quot;<input name=field1 value=&quot;&cField1&&quot;>&quot;




br
Gerard
 
okay - just a thought here...

if i have this correctly, you have a bunch of form fields, and one of them is a drop-down box. onchange of the dropdown box, you want it to reload the page, and keep all the fields' values intact.

when you do your onchange event, you're probably just reloading the page, and the fields that have data aren't being submitted, so it's not going to be able to use those values.

you could change your &quot;onchange&quot; event for your dropdown box to do a form.submit, instead of loading the target page. this way, you could do a request.form() to get each of your form fields values, and insert them back into the form fields. you'd just have to know that if your script is repopulating itself, then it needs to do a request.form and grab all the values and stick them back into the fields.

hope this helps...
 
FYI - There are some FAQs on doing remote scripting - which would more seamlessly accomplish what you're looking for. I've heard that it's not extremely simple to set up, but it works well when it's done.

perhaps you should take a look at doing that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top