473,395 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Form reloads

JJ
Hi All,

When someone selects a value in a select on a form I want to show the
same form with another select with certain values depending on first select.
How can I do this? Should I keep acouple of arrays loaded with the second
selects values not to be shown till selected in first or what other means?

Also how do you reload the current form to show maybe a nex field or select
box?

Thanks,

JJ
Jul 19 '05 #1
2 3733
it's a clientside event but have the onChange() trigger a form.submit()

--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
...Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"JJ" <jm***@bellatlantic.net> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
Hi All,

When someone selects a value in a select on a form I want to show the
same form with another select with certain values depending on first select. How can I do this? Should I keep acouple of arrays loaded with the second
selects values not to be shown till selected in first or what other means?

Also how do you reload the current form to show maybe a nex field or select box?

Thanks,

JJ

Jul 19 '05 #2
You can use dependent listboxes for example to let a user choose a rep
in a reps listbox and then have only the customers for that rep be shown
in the customers listbox.

You can see an example of this on the ASP Web database demo on my site
www.bullschmidt.com/login.asp and then go to the Invoices dialog and
choose a rep in the listbox and notice that the page is posted to
itself, the customers listbox then gets the focus, and the customers
listbox only contains the customers for that rep.

I'd suggest having the onchange event for the first listbox (called
RepID) use JavaScript to submit the page (assuming the page is being
posted back to itself anyway) and then if the page is a post, show the
extra info in the second listbox.

Example:
<select name="RepID" size="1" onchange="RefreshPg('CustID');">

And the SQL for the second listbox (called CustID) would be something
like this:
strSQL = "SELECT CustID "
strSQL = strSQL & "FROM tblCust "
strSQL = strSQL & "WHERE (1=1) "
If Request.Form("RepID") <> "" Then
strSQL = strSQL & "AND (CustUserID=" & Chr(39) & Request.Form("RepID")
& Chr(39) & ") "
End If
strSQL = strSQL & "ORDER BY CustID"

And on the form have a hidden field which will contain the name of the
field to be given the focus when the page is reopened.

Example:
<input type="hidden" name="FocusedFldName" value="<%=
Request.Form("FocusedFldName") %>">

And somewhere on the page:
<% ' Set focus.
If Request.Form("FocusedFldName") <> "" Then
' Set focus based on FocusedFldName.
%>
<script type="text/javascript">document.frmMain.<%=
Request.Form("FocusedFldName") %>.focus();</script>
<% Else
' Set focus.
%>
<script type="text/javascript">document.frmMain.RepID.focus();</script>
<% End If %>

And here's the JavaScript function to submit the page for this purpose:

function RefreshPg(pstrFldName) {
// Purpose: Refresh pg. to update other fld(s) based on selection.
// Remarks: Used by listbox's onchange.
// Assumes existence of document.frmMain.FocusedFldName hidden fld.

// Set focused fld for when come back.
document.frmMain.FocusedFldName.value = pstrFldName;

// Msg.
alert("Refreshing page to update other field(s) based on your
selection.");

// Submit pg to itself to refresh other combo based on this combo.
document.frmMain.submit();
}

And here are some final notes of clarification.

FocusedFldName is the name of a hidden field on the form. It is usually
blank but after the user changes the parent listbox (called RepID)
JavaScript code puts in the name of the child listbox (called CustID)
into the hidden field (called FocusedFldName) on the form.

Then when the page is reopened JavaScript sets the focus on the name of
the field (i.e. the name of the child listbox) contained in the hidden
field. Thus the focus is set on the CustID field (instead of the RepID
field which gets the focus when the form is FIRST opened).

And if the RepID field in the database is a numeric field then the
Chr(39) stuff is not needed so this:
strSQL = strSQL & "AND (CustUserID=" & Chr(39) & Request.Form("RepID")
& Chr(39) & ") "
Should be changed to this:
strSQL = strSQL & "AND (CustUserID=" & Request.Form("RepID") & ") "

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Virgil Hobbs | last post by:
What programming codes will enable me to achieve interaction between vb or c# and HTML form values, without a page reload occurring every time a script is run? At least with javascript and vb...
10
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
1
by: Frawls | last post by:
Hi Can any one give me some help with this problem please? Here is the scenario: A user submits page 1 which is a web form. After the form has been submitted they are (redirected) onto...
2
by: Frawls | last post by:
Hi Can any one give me some help with this problem please? Here is the scenario: A user submits page 1 which is a web form.
7
by: Grant Merwitz | last post by:
Hi I am trying to get the enter key to submit my login form The login form is currently in a control on the page and uses an asp:imagebutton as it's login button. If a user presses enter...
1
by: AC | last post by:
Hi, I have the following code for my form, which is supposed to update a grade integer field and a text area, but when I click the submit button, instead of sending the user to the page...
3
by: drblitzkrieg | last post by:
Hi, I have a page with 2 drop-down menus. The task is, when you select 1 menu, your selection then changes the options available in the other. This data happens to be drawn from a mysql database,...
2
by: rynato | last post by:
I have a form which the user fills out to enter some data. If there already exists an uncompleted session - say, the user started entering some data but had to stop to do something else - the...
5
by: g | last post by:
Hi Guys.. i know this might sound really really simple, but I'm kinda stuck..I have this form..which has a table (created from stored procedure values)..once the table is populated..i have some...
9
by: mel | last post by:
Hi all, I need a persistent TCP connection with my web server over page reloads. This means that, even if the user goes to a different page (in my domain), I want to keep a TCP connection...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.