By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,137 Members | 2,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,137 IT Pros & Developers. It's quick & easy.

asp session help

P: n/a
-D-
I'm trying to accomplish the following. I'm trying to get the values for the
table rows that are dynamically created to persist through a redirect.

Referring URL:
http://www.dwayneepps.com/abr_site/fundingrequest.asp

If you click on the "New Transaction" button it will generate a new row for
the user to input information. I call a javascript function when the user
clicks the "New Transaction" button that redirects to another page that
processes some ASP code that builds a new row. I use a loop to create the
table rows by incrementing a session variable everytime the user clicks on
the "New Transaction" button.

Here is the structure of the loop:
<%
Session("url") = 2
Dim x
For x = 0 to Session("TotalRowsB")
%>
<tr>
<td><input name="yr<%=x%>" type="text" id="yr<%=x%>"
value="<%=Session("yr")%>" size="5" maxlength="25"></td>
<td><select name="strategy<%=x%>">
<option selected>-select-</option>
</select></td>
<td><input name="BA<%=x%>" type="text" value="" size="15"></td>
<td><select name="BO<%=x%>">
<option selected>-select-</option>
</select></td>
<td><input name="origBA<%=x%>" type="text" value="10,000,000.00"
size="15" maxlength="100" readonly="true"></td>
<td><input name="IncrDecr<%=x%>" type="text" value=""
size="10"></td>
</tr>
<%
Next
%>

The field names increment by one for every new row that is created. For
example, the field "yr" would be "yr1", "yr2", "yr3" on each pass through
the loop.

I'm lost on how to maintain the user's input when a new row is created. I'm
thinking I can use a session variable, but I'm not sure how to capture the
user's input into the session variable.

Any help is greatly appreciated. Thanks.
-D-
Jul 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi -D-,

One of the things that you could do is write the current input into session
variables as you suggested, and then repopulate the values when you reload
the page. Another option is to have the form post right back to
fundingrequest.asp instead of abrinsert.asp. That way, your post data is
available in the page already, and you can just use the request.form data
that has already been entered. There are issues with doing this, though.
Like, if someone presses Enter or Ctrl+M to submit the form, you have to
make sure your code will know what action to take (reload page with new row
or process data).

Another option is just to use client-side code if you want to be daring with
your visitors' browsers...
<input name="btnNewRow" type="button" id="btnNewRow" value="New Transaction"
onClick="addRow()">
<script type="text/javascript">
var iRowCount = 0; //3? constant? generated from asp?
function addRow() {
iRowCount++;
var oTable = document.getElementById('details')
var oTbody = oTable.getElementsByTagName('TBODY')[0];
var oRow = document.createElement('TR');
oRow.id = 'trTrans' + iRowCount;

var oTD1 = document.createElement('TD');
oTD1.innerHTML = tdYear(iRowCount);

var oTD2 = document.createElement('TD');
oTD2.innerHTML = tdStrategy(iRowCount);

var oTD3 = document.createElement('TD');
oTD3.innerHTML = tdBudget(iRowCount);

var oTD4 = document.createElement('TD');
oTD4.innerHTML = tdBudgetObject(iRowCount);

var oTD5 = document.createElement('TD');
oTD5.innerHTML = tdOrigBudget(iRowCount);

var oTD6 = document.createElement('TD');
oTD6.innerHTML = tdIncDec(iRowCount);

oRow.appendChild(oTD1);
oRow.appendChild(oTD2);
oRow.appendChild(oTD3);
oRow.appendChild(oTD4);
oRow.appendChild(oTD5);
oRow.appendChild(oTD6);
oTbody.appendChild(oRow);

}

function tdYear(n) {
var s;
s = '<input name=\"yr' + n + '\" type=\"text\" id=\"yr' + n + '\"
size=\"5\" maxlength=\"25\">'
return s;
}

function tdStrategy(n) {
var s;
s = '<select name=\"strategy' + n + '\">\n';
s+= '\t<option selected>-select-</option>\n';
//loop through options here, assuming there will be some!
s+='</select>'
return s;
}

function tdBudget(n) {
var s;
s = '<input name=\"BA' + n + '\" type=\"text\" size=\"15\">';
return s;
}

function tdBudgetObject(n) {
var s;
s = '<select name=\"origBA1' + n + '\">\n';
s+= '\t<option selected>-select-</option>\n';
//loop through options here, assuming there will be some!
s+='</select>'
return s;
}

function tdOrigBudget(n) {
var s;
s = '<input name=\"origBA' + n + '\" type=\"text\" value=\"10,000,000.00\"
size=\"15\" maxlength=\"100\" readonly=\"true\">';
return s;
}

function tdIncDec(n) {
var s;
s = '<input name=\"IncrDecr' + n + '\" type=\"text\" size=\"10\">';
return s;
}
</script>

Ray at home

"-D-" <no***@nospam.com> wrote in message
news:eM**************@TK2MSFTNGP11.phx.gbl...
I'm trying to accomplish the following. I'm trying to get the values for
the
table rows that are dynamically created to persist through a redirect.

Referring URL:
http://www.dwayneepps.com/abr_site/fundingrequest.asp

If you click on the "New Transaction" button it will generate a new row
for
the user to input information. I call a javascript function when the user
clicks the "New Transaction" button that redirects to another page that
processes some ASP code that builds a new row. I use a loop to create the
table rows by incrementing a session variable everytime the user clicks on
the "New Transaction" button.

Here is the structure of the loop:
<%
Session("url") = 2
Dim x
For x = 0 to Session("TotalRowsB")
%>
<tr>
<td><input name="yr<%=x%>" type="text" id="yr<%=x%>"
value="<%=Session("yr")%>" size="5" maxlength="25"></td>
<td><select name="strategy<%=x%>">
<option selected>-select-</option>
</select></td>
<td><input name="BA<%=x%>" type="text" value="" size="15"></td>
<td><select name="BO<%=x%>">
<option selected>-select-</option>
</select></td>
<td><input name="origBA<%=x%>" type="text" value="10,000,000.00"
size="15" maxlength="100" readonly="true"></td>
<td><input name="IncrDecr<%=x%>" type="text" value=""
size="10"></td>
</tr>
<%
Next
%>

The field names increment by one for every new row that is created. For
example, the field "yr" would be "yr1", "yr2", "yr3" on each pass through
the loop.

I'm lost on how to maintain the user's input when a new row is created.
I'm
thinking I can use a session variable, but I'm not sure how to capture the
user's input into the session variable.

Any help is greatly appreciated. Thanks.
-D-

Jul 22 '05 #2

P: n/a
-D-
Hi Ray,

Thank you for replying to my post. I appreciate the help. How can I
capture the users input into a session variable before the user submits the
form?

When a user enters a value into a form field, can I set the session variable
to that value immediately?

Session("myvariablename") = ???

Is the Request.Form collection still available before the form is submitted?

Session("myvariablename") = Request.Form("yr")

Thanks again for the help.
-D-
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:eJ*************@TK2MSFTNGP12.phx.gbl...
Hi -D-,

One of the things that you could do is write the current input into session variables as you suggested, and then repopulate the values when you reload
the page. Another option is to have the form post right back to
fundingrequest.asp instead of abrinsert.asp. That way, your post data is
available in the page already, and you can just use the request.form data
that has already been entered. There are issues with doing this, though.
Like, if someone presses Enter or Ctrl+M to submit the form, you have to
make sure your code will know what action to take (reload page with new row or process data).

Another option is just to use client-side code if you want to be daring with your visitors' browsers...
<input name="btnNewRow" type="button" id="btnNewRow" value="New Transaction" onClick="addRow()">
<script type="text/javascript">
var iRowCount = 0; //3? constant? generated from asp?
function addRow() {
iRowCount++;
var oTable = document.getElementById('details')
var oTbody = oTable.getElementsByTagName('TBODY')[0];
var oRow = document.createElement('TR');
oRow.id = 'trTrans' + iRowCount;

var oTD1 = document.createElement('TD');
oTD1.innerHTML = tdYear(iRowCount);

var oTD2 = document.createElement('TD');
oTD2.innerHTML = tdStrategy(iRowCount);

var oTD3 = document.createElement('TD');
oTD3.innerHTML = tdBudget(iRowCount);

var oTD4 = document.createElement('TD');
oTD4.innerHTML = tdBudgetObject(iRowCount);

var oTD5 = document.createElement('TD');
oTD5.innerHTML = tdOrigBudget(iRowCount);

var oTD6 = document.createElement('TD');
oTD6.innerHTML = tdIncDec(iRowCount);

oRow.appendChild(oTD1);
oRow.appendChild(oTD2);
oRow.appendChild(oTD3);
oRow.appendChild(oTD4);
oRow.appendChild(oTD5);
oRow.appendChild(oTD6);
oTbody.appendChild(oRow);

}

function tdYear(n) {
var s;
s = '<input name=\"yr' + n + '\" type=\"text\" id=\"yr' + n + '\"
size=\"5\" maxlength=\"25\">'
return s;
}

function tdStrategy(n) {
var s;
s = '<select name=\"strategy' + n + '\">\n';
s+= '\t<option selected>-select-</option>\n';
//loop through options here, assuming there will be some!
s+='</select>'
return s;
}

function tdBudget(n) {
var s;
s = '<input name=\"BA' + n + '\" type=\"text\" size=\"15\">';
return s;
}

function tdBudgetObject(n) {
var s;
s = '<select name=\"origBA1' + n + '\">\n';
s+= '\t<option selected>-select-</option>\n';
//loop through options here, assuming there will be some!
s+='</select>'
return s;
}

function tdOrigBudget(n) {
var s;
s = '<input name=\"origBA' + n + '\" type=\"text\" value=\"10,000,000.00\" size=\"15\" maxlength=\"100\" readonly=\"true\">';
return s;
}

function tdIncDec(n) {
var s;
s = '<input name=\"IncrDecr' + n + '\" type=\"text\" size=\"10\">';
return s;
}
</script>

Ray at home

"-D-" <no***@nospam.com> wrote in message
news:eM**************@TK2MSFTNGP11.phx.gbl...
I'm trying to accomplish the following. I'm trying to get the values for
the
table rows that are dynamically created to persist through a redirect.

Referring URL:
http://www.dwayneepps.com/abr_site/fundingrequest.asp

If you click on the "New Transaction" button it will generate a new row
for
the user to input information. I call a javascript function when the user clicks the "New Transaction" button that redirects to another page that
processes some ASP code that builds a new row. I use a loop to create the table rows by incrementing a session variable everytime the user clicks on the "New Transaction" button.

Here is the structure of the loop:
<%
Session("url") = 2
Dim x
For x = 0 to Session("TotalRowsB")
%>
<tr>
<td><input name="yr<%=x%>" type="text" id="yr<%=x%>"
value="<%=Session("yr")%>" size="5" maxlength="25"></td>
<td><select name="strategy<%=x%>">
<option selected>-select-</option>
</select></td>
<td><input name="BA<%=x%>" type="text" value="" size="15"></td>
<td><select name="BO<%=x%>">
<option selected>-select-</option>
</select></td>
<td><input name="origBA<%=x%>" type="text" value="10,000,000.00"
size="15" maxlength="100" readonly="true"></td>
<td><input name="IncrDecr<%=x%>" type="text" value=""
size="10"></td>
</tr>
<%
Next
%>

The field names increment by one for every new row that is created. For
example, the field "yr" would be "yr1", "yr2", "yr3" on each pass through the loop.

I'm lost on how to maintain the user's input when a new row is created.
I'm
thinking I can use a session variable, but I'm not sure how to capture the user's input into the session variable.

Any help is greatly appreciated. Thanks.
-D-


Jul 22 '05 #3

P: n/a

"-D-" <no***@nospam.com> wrote in message
news:up*************@TK2MSFTNGP12.phx.gbl...
Hi Ray,

Thank you for replying to my post. I appreciate the help. How can I
capture the users input into a session variable before the user submits
the
form?

When a user enters a value into a form field, can I set the session
variable
to that value immediately?
You cannot. The user must submit the form before your server can get the
value and store it in a session variable.

Is the Request.Form collection still available before the form is
submitted?


No, because the session data exists on the server, so the server, once it
delivers the page back to the browser, will not know what the user has done
until another request is made to the server, i.e. the form is submitted.

I think that your best bet is probably to post back to the same page.

Ray at home
Jul 22 '05 #4

P: n/a
-D-
Ray,
I'm trying to think through the logic for how to code the page if it posts
back to itself. Right now, I have a function that I call to redirect to
the page that processes the ASP code to build the new table rows
dynamically:

function BuildRows() {
location.replace('buildrows.asp')
}

The "New Transactions" button calls this function:
<input name="btnNewRow" type="button" id="btnNewRow" value="New Transaction"
onClick="BuildRows()">

I have a submit button at the bottom of the form that will actually insert
the information into the database.

So, I'm thinking I need to have the "New Transaction" button submit the form
to itself and then re-direct to the page that processes the ASP code to
build the table rows dynamically.

Is there a way to modify the function to submit the form to itself first and
then re-direct to the buildrows.asp page. That way, the server has the form
values and I can set the session variables.

The logic on this one is a little confusing to me...
-D-
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:#x**************@TK2MSFTNGP14.phx.gbl...

"-D-" <no***@nospam.com> wrote in message
news:up*************@TK2MSFTNGP12.phx.gbl...
Hi Ray,

Thank you for replying to my post. I appreciate the help. How can I
capture the users input into a session variable before the user submits
the
form?

When a user enters a value into a form field, can I set the session
variable
to that value immediately?
You cannot. The user must submit the form before your server can get the
value and store it in a session variable.

Is the Request.Form collection still available before the form is
submitted?


No, because the session data exists on the server, so the server, once it
delivers the page back to the browser, will not know what the user has

done until another request is made to the server, i.e. the form is submitted.

I think that your best bet is probably to post back to the same page.

Ray at home

Jul 22 '05 #5

P: n/a
You can certainly write to the session variables as soon as the form posts
back to itself..

jeff

"-D-" <no***@nospam.com> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Ray,
I'm trying to think through the logic for how to code the page if it posts
back to itself. Right now, I have a function that I call to redirect to
the page that processes the ASP code to build the new table rows
dynamically:

function BuildRows() {
location.replace('buildrows.asp')
}

The "New Transactions" button calls this function:
<input name="btnNewRow" type="button" id="btnNewRow" value="New Transaction" onClick="BuildRows()">

I have a submit button at the bottom of the form that will actually insert
the information into the database.

So, I'm thinking I need to have the "New Transaction" button submit the form to itself and then re-direct to the page that processes the ASP code to
build the table rows dynamically.

Is there a way to modify the function to submit the form to itself first and then re-direct to the buildrows.asp page. That way, the server has the form values and I can set the session variables.

The logic on this one is a little confusing to me...
-D-
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:#x**************@TK2MSFTNGP14.phx.gbl...

"-D-" <no***@nospam.com> wrote in message
news:up*************@TK2MSFTNGP12.phx.gbl...
Hi Ray,

Thank you for replying to my post. I appreciate the help. How can I
capture the users input into a session variable before the user submits the
form?

When a user enters a value into a form field, can I set the session
variable
to that value immediately?


You cannot. The user must submit the form before your server can get the value and store it in a session variable.

Is the Request.Form collection still available before the form is
submitted?


No, because the session data exists on the server, so the server, once it delivers the page back to the browser, will not know what the user has

done
until another request is made to the server, i.e. the form is submitted.

I think that your best bet is probably to post back to the same page.

Ray at home


Jul 22 '05 #6

P: n/a
Hi -D-,

Not ignoring thread. Will look at again tonight after work. The
combination of dynamically generated rows of form fields and saving existing
data makes this a bit more involved than just a quick answer. :]

Ray at work

"-D-" <no***@nospam.com> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Ray,
I'm trying to think through the logic for how to code the page if it posts
back to itself. Right now, I have a function that I call to redirect to
the page that processes the ASP code to build the new table rows
dynamically:

function BuildRows() {
location.replace('buildrows.asp')
}

Jul 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.