Suntower
Posts: 225
|
| Posted: 08/14/2006, 3:19 PM |
|
I have a typical database update form. There is a field called 'ShipToID' which is linked to a table of Ship To Addresses.
I want the user to be able to select from this list using a listbox, then press a 'Select' button and have the full address display in labels to the right of the list box.
I add a button and listbox to the form and the selection works OK, except that:
1. When the user presses the Select button, it re-loads the page and does not 'remember' the selected value in the Listbox. IOW: The listbox reloads to the default 'Select Value'.
2. The labels at right never display the proper values even though I am properly assigning them in the OnClick() property.
I think what is happening is that...
1. The user presses 'Select' which reloads the page but
2. The selected Ship To ID is being 'lost' ie. when the page reloads it is not getting the proper ShiptoID (from the listbox) parameter passed in the URL.
So... is there a way to have the user press the 'Select' button and reload the page but -remember- the starting value of the listbox AND remember the ShipToID parameter?
Side Question #1: How do I check the response string being passed back to the page when the user presses the 'Select' button (ie. as the page reloads)?
Side Question #2: How do I -force- the parameter to be posted back if it turns out that the parameter is not being passed?
THANKS!
---JC
_________________
---On a campaign for more examples and better docs! |
 |
 |
wkempees
Posts: 1679
|
| Posted: 08/14/2006, 5:38 PM |
|
First things first.
"shipping address is never displaying the right values".
Your record form is on table A, displaying all the correct values, because it's SQL is getting all the fields and displaying them.
So, your ShipToID is filled as well? Check your SQL.
To get the shipping address to display correct you need to expand on the SQL and join in your shipping addresses table.
select * from tableA
left join tableB on tableB.id = tableA.ShipToID
This will make the shipping address data available to the Form.
Of course you substitute TableA/B with the correct tablenames and check that all the Shipping address label are in fact bound to the SQL fields.
That's one covered.
Now for the Listbox, the easiest way to get this working fast
is to delete the listbox you have now, put a textbox on the form for ShipToID
Go to Live form and check that ShipToID displays the correct integer value for the displayed shipping address (the one you just made work.
If it displays ok, then in Designmode, rightclick this field and ChangeTo a Listbox, select the correct table in the DataSource property, set the Bind and Text fields, and everything should work like a charme.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
Suntower
Posts: 225
|
| Posted: 08/15/2006, 10:36 AM |
|
This is one of those 'one picture' is worth a thousand words' deals. I -do- have the proper SQL.
The form -does- have the proper ShipToID when it loads. And I can get it to display the proper child table (ShipTos) info when the page loads.
I can also get the listbox to display the ShipTos selections.
But what I -can't- get to work is that the shipping address info dynamically updates as the user selects a Shipping Address.
I assumed from what you wrote that if I simply added the ShipTos table to the form's query, when the user changed values in the listbox (which is bound to the ShipToID of the parent table of the form 'Orders') that the values in the child table (ShipTos) would change---giving the user the proper feedback as to their selection.
This doesn't happen. Scrolling through the list does -not- change the values of the Ship To Address.
That's why I added a button 'Select'. I assumed that the page would have to re-load in order to update the Ship To labels.
BUT if I do -that- the page -does- reload however the same fields are re-loaded. IOW: I want the newly selected Listbox choice to display. But of course it doesn't---when the page reloads it simply loads the original value from the database row on disk.
Can you help?
---JC
_________________
---On a campaign for more examples and better docs! |
 |
 |
Waspman
Posts: 948
|
| Posted: 08/16/2006, 1:42 AM |
|
Have you tried using on change?
I do this using iframes, but it all depends on your input structure.
I'm sure I've seen this done using code to refresh only the relevant fields.
Try Google.
Sounds a bit like dependant listbox thingy.
Tony
_________________
http://www.waspmedia.co.uk |
 |
 |
WKempees
|
| Posted: 08/16/2006, 3:40 AM |
|
> The form -does- have the proper ShipToID when it loads. And I can get it
> to
> display the proper child table (ShipTos) info when the page loads.
that's step one covered.
> I can also get the listbox to display the ShipTos selections.
> But what I -can't- get to work is that the shipping address info
> dynamically
> updates as the user selects a Shipping Address.
This will need iFrame or Ajax like Asynchronic stuff, which because you use
ASP I will have to pass on.
There is an Example of this in either the Examples or the ExamplePack2, will
have to go and find it.
> I assumed from what you wrote that if I simply added the ShipTos table to
> the
> form's query, when the user changed values in the listbox (which is bound
> to
> the ShipToID of the parent table of the form 'Orders') that the values in
> the
> child table (ShipTos) would change---giving the user the proper feedback
> as to
> their selection.
The assumption is partly right, if a value is taken from the Listbox,
stuffed in the ShipToID
and in the right place, the page submit would have to refresh the child
table (ShipTos) info.
But thinking about this, if the SQL is a Join, and you refresh the page
without actually updating the
Row in the database, the upon show it would still show the 'old' info.
> This doesn't happen. Scrolling through the list does -not- change the
> values of
> the Ship To Address.
See text about the Examples
> That's why I added a button 'Select'. I assumed that the page would have
> to
> re-load in order to update the Ship To labels.
>
> BUT if I do -that- the page -does- reload however the same fields are
> re-loaded. IOW: I want the newly selected Listbox choice to display. But
> of
> course it doesn't---when the page reloads it simply loads the original
> value
> from the database row on disk.
>
So my help would be read up on the example http://examples.codecharge.com/CCSExamplePack2/Retrievi...ieldsValues.php
And to change the focus on the problem.
How about, unJOINing the shippinf data from the main SQL.
So the from only runs on the SQL it is supposed to use for Update / Delete.
On the one hand this could eliminate the need for custom update /delete, on
the other hand
we could CCDLookup(), DLookup() or manualy lookup the ShipTo info in the
Before Show.
Now when the listbox is used to pick a different value from the ShipTo the
OnChange could do a Form Submit
or you yould use your 'select'button approach, but not after you have made
sure that the next refresh
will obey the new ShipToID. So in the before show you would need some sort
of test to see if the one ID matches the Other.
I hope this helps,
Walter
|
|
|
 |
|