Rob Bakker
|
| Posted: 06/30/2003, 11:21 PM |
|
I'm using an editable grid where every record has a link to a new page, where the user can fill in more details about the specific record.
My problem is that sometimes users fill in all fields in the grid (20 records with 3 editable fields), then, before clicking the "update-button", click on a link to fill in the details of a record. The result is, that all updates they made on the editable grid are lost.
The easiest solution is to instruct the users to use the update-button or press Enter before they click on the link, but, as you all know, users never follow instructions!
So I'm looking for a way to force a submit of the page before following the link to the details-page. A link has no "on-click" event so it is not possible to add the action "Submit Form". When I use a button instead of a link, I can submit the form and redirect to the the details-page, but I cannot give the key of the specific record to the the details-page.
I tried using a "submit form" action on the "on change" event of the editable fields, but that has 2 major disadvantages:
1. when the user edits 60 fields, all 20 records are udated 60 times.
2. using the tab-key is impossible, because, after every submit the cursor goes to the initial position.
I tried several other solutions, but nothing seems to work.
I'm using the latest version of CCS with ASP.
All suggestions will be highly appreciated.
|
|
|
 |
rrodgers
|
| Posted: 07/01/2003, 5:23 AM |
|
It has a client side onclick event. Click on your link. Then click on the format tab in the Properties tool window. Click on the + next to the events. Add this code to the onclick event. Change HTMLFormName to either the variable used for your form name or change it to the real name of your form.
javascript:document.{HTMLFormName}.submit()
I haven't tried this on a link but have used it quite a bit on list boxes onchange event and it works fine.
rob
|
|
|
 |
Rob Bakker
|
| Posted: 07/01/2003, 6:53 AM |
|
I'm afraid your suggestion does not work on a link. I tried it and there was no submit. With a listbox CSS shows the on change event on the client. If you add a submit action to this event, CSS binds this event in your HTML and it works. For a link however CSS only offers a beforeshow event on the client.
Maybe I can bind the event myself, but I'm don't know how.
Adding the code you provided to the onclick event in the format/Events tab doesn't work.
Thanks anyway.
Rob
|
|
|
 |
rrodgers
|
| Posted: 07/01/2003, 7:45 AM |
|
>>For a link however CSS only offers a beforeshow event on the client.
Read my response carefully. I explained how to get to the true html events. The reference for a <link> says it does support a onclick event. So it should work.
A good reference site... http://www.w3schools.com/html/html_reference.asp
rob
|
|
|
 |
cornwell
|
| Posted: 07/01/2003, 10:26 PM |
|
1. I think he means work in the HTML mode, not design mode.
2. The bad news is that whatever you do, there are some events you won't trap and therefore your data may not be protected.
Client might pick a "Favorite", click "Back" button, close the browser, type in a URL, select a URL from the History --- none of which you'll be preventing!
Sure, you might get an auto-submit on YOUR link - but if client is careless any data can go west.
It boils down to clients having a bit of training and working with common sense. I suppose .NET with it's data persistence might offer you a way out?
Good luck.
|
|
|
 |
rrodgers
|
| Posted: 07/02/2003, 8:51 AM |
|
>>
Client might pick a "Favorite", click "Back" button, close the browser, type in a URL, select a URL from the History --- none of which you'll be preventing!
<<
Sure but he was asking about a link "<a>" that would allow his users to goto another page where they enter more details for the record. I did some tests and was able to get the editable grid to update the changed values very easily when clicking on a link. I couldn't get it to work when there was a href value but if you leave that blank or use a # then the submit happens as expected. I added a little code to the AfterSubmit event to modify the Redirect Variable so it included the correct record identifier before calling the record detail form and all was well.
rob
|
|
|
 |
Rob Bakker
|
| Posted: 07/03/2003, 12:16 AM |
|
First of all thanks for your replies.
I'm well aware that my solution is a) dangerous because the user will submit values without knowing that and b) inadequate because this will not tackle all user actions, like clicking on a hyperlink, etc.
However, it will deal with the situation that a user has filled a spreadsheet-like page and decides to add details to some records before submitting the page.
I tried using the onclick event with the provided javascript, but nothing happened. Here is an example of my code:
<a title="Details" onclick="javascript:document.Budget.submit();" href="{DetailsLink_Src}">{DetailsLink}</a>
To verify whether the script was executed I added a second line with a confirm popup:
<a title="Details" onclick="javascript:document.Budget.submit();confirm('OK?');" href="{DetailsLink_Src}">{DetailsLink}</a>
To my suprise the submit was executed!
Using a window.alert did the trick as well. I don't understand why this happens. Could it be possible that browser-settings or CSS coding are the reason for this strange phenomena?
I don't want a popup every time a user clicks the link, so I will try if it works when I use another statement.
In the latest reply you mentioned that using a href value could be a problem. I will try that out as well.
|
|
|
 |
|