The ASP 2.0 (and I assume you *really* mean ASP.NET 2.0) is irrelevant.
This would be completely a client-side javascript solution.
It's not hard, just tedious. You have to put an onchange="this.form.ddl_status.selectedIndex=0;" into each form field.
For form field types that don't support onchange (e.g., a set of radio buttons) you'd put the same JS code into their onclick handlers. I can't think of any form field types offhand that you couldn't manage with one or the other of those.
Naturally, if "Being Worked On" is not the first <option> in the <select> then change the 0 for selectedIndex as appropriate.
And naturally you could make a function that would do the same thing and invoke the function from each place. Might make it look neater, but wouldn't change the work or the effect.
There is a slight problem in that although changing a form element will change the dll selected index, the user can immediately alter it back again. Perhaps the following is what is wanted, although in truth I am finding it hard to see the purpose. But of course the dll could be re-enabled by something if required.
Code:
<select id = "fruits">
<option value = "1"> Apple<br>
<option value = "2"> Pear<br>
<option value = "3"> Being Worked On<br>
</select>
<br><br>
<input type = "button" value = "change" onclick = "changeSel()">
<script type = "text/javascript">
function changeSel() {
document.getElementById("fruits").selectedIndex = 2;
document.getElementById("fruits").disabled = true;
}
</script>
As you say, the button should be replaced in evey form field instance by a call to the function.
Last edited by Philip M; 05-25-2009 at 08:39 PM..
Reason: Typo
I was assuming that the purpose of the DDL was that the user is *REQUIRED* to change it from "Being Worked On" to "Form Completed" as confirmation that he/she really did check that all the needed changes had been applied.
If the user is presented with an already filled out (or partially filled out) <form>, then this kind of makes sense. He/she can't hit the SUBMIT button until confirming that he/she had checked everything twice.
Seems to me, though, that there would be better things to use than a <SELECT> for this purpose. For example, maybe just a checkbox that says "I certify that I have double checked all the stuff in this form and it's all correct and you can fire me immediately if I screwed up." And every time there is a change, the code unchecks the box. Oh...and the submit button is of course disabled until the box is checked.
There is a slight problem in that although changing a form element will change the dll selected index, the user can immediately alter it back again. Perhaps the following is what is wanted, although in truth I am finding it hard to see the purpose. But of course the dll could be re-enabled by something if required.
Code:
<select id = "fruits">
<option value = "1"> Apple<br>
<option value = "2"> Pear<br>
<option value = "3"> Being Worked On<br>
</select>
<br><br>
<input type = "button" value = "change" onclick = "changeSel()">
<script type = "text/javascript">
function changeSel() {
document.getElementById("fruits").selectedIndex = 2;
document.getElementById("fruits").disabled = true;
}
</script>
As you say, the button should be replaced in evey form field instance by a call to the function.
Hi, Ive gone for this option - many thanks for your help.
Just one question - Ive tried using W as the selected value eg;
Code:
<select id = "list_status">
<option value = "P">Pending<br>
<option value = "W">Worked On<br>
<option value = "C">Closed<br>
</select>
<br><br>
<input type = "button" value = "change" onclick = "changeSel()">
<script type = "text/javascript">
function changeSel() {
document.getElementById("list_status").selectedIndex = "W";
document.getElementById("list_status").disabled = true;
}
</script>
But it doesnt seem to like using Letters instead of numbers - any idea why?
ive had a little problem with this. I need to reference the list in the vb code file behind the aspx page. To due this I have to set the run="server" attribute :