Hi
Ok.. why not put the ID of item edited into a hidden input
as the dropdown will change ..
<html>
<head>
<script>
function doConfirm(f){
var bIsDirty = 0;
var e;
// You can check element type & compare defaultValue to value
// The defaultValue is what you populate on the server
// for simplicity I only check type = text/textarea
// radio/checkbox have defaultChecked which you can check also
for(i=0;i<f.elements.length;i++)
{
e = f.elements[i];
if(e.type == "text" || e.type == "textarea") if(e.defaultValue !=
e.value) bIsDirty = 1;
}
if( bIsDirty ) f.bDoSave.value = confirm("Item changed!!\n\nDo you want to
save?") ? 1 : 0;
f.submit();
// If you are using validators you can call the click method of the
submitbtn
// instead of f.submit();
// do f.mySubmitBtn.click();
}
</script>
</head>
<body>
<form>
<select onchange="doConfirm(this.form)" name="mySelect">
<option value="1">blah1</option>
<option value="2" selected>blah2</option>
</select>
<input type="hidden" name="myHiddenID" value="2"> <!-- Store ID here, same
as the selected one in the dropdown -->
<input type="hidden" name="bDoSave" value="0"> <!-- push save flag here,
default 0 -->
<input type="text" name="myInput1" value="SOMEVALUE">
<input type="text" name="myInput2" value="SOMEVALUE">
<textarea name="myTextArea">blah blah</textarea>
</form>
</body>
</html>
More info:
http://msdn.microsoft.com/library/de...ence_entry.asp
--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/ http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground:
http://213.190.104.211/ ( IE 5.5+ only )
No matter where you go there you are
==============================
"Andy" <ne*****************@hotmail.com> wrote in message
news:9e**************************@posting.google.c om...
So, the onchange event for the textbox sets the flag anychange to
true. The dropdownlist, when changed, fires the event which checks the
flag.
When testing, I took the approach that I would ask the user if they
wanted to save and triggered the following on listbox change.
<script>
function AskUser()
{
var answer = window.confirm("Do you want to save?")
document.forms(0).answer.value = String(answer)
document.forms(0).submit()
}
</script>
But I had 2 problems
1) I couldnt work out how to get the True\False from the confirm to
either save then go and get the new data for the list box item, or
just go and get the new data for the list box item (without saving).
2) At the point at which the above event fires, the list box has
already changed, and Ive lost the original listbox item, which is what
I need when running the save in the code behind.
I hope these questions are sensible and that somebody can put me out
of my misery.
:-(