aspose file tools*
The moose likes JSP and the fly likes onchange event of drop down list  - problem F1 pls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "onchange event of drop down list  - problem F1 pls" Watch "onchange event of drop down list  - problem F1 pls" New topic
Author

onchange event of drop down list - problem F1 pls

river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
I have a drop down list from the JSP and here are the scenarios:
say I have values for the drop down as: (example)
-SAVE-
-DELETE-
-UPDATE-
By defualt upon initial loading of the JSP the value will be UPDATE.....since I used the "onchange event" of the drop down list nothing happen when the user choose the same defualt values..unless I choose other values say "DELETE" then choose "UPDATE" back again then it works.....
Scenarios:
1) choose default value....nothing happen
2) I choose values other than default... it works
3) I choose again the defualt values..it work...
Limitations:
I cannot eliminate putting a defualt values to the dropdown upon loading
Can someone help on any event or ways possible that even if i choose the default values of the dropdown it will still perform the javascript function I want....
Thanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

This is hardly a JSP question. You'd probably get more responses if you had a sheriff move this to the HTML/Javascript forum.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
A cheap and easy workaround for this is to add a blank or informational option to the beginning of your list:
<SELECT>
<option value="">
<option value="update">-UPDATE-
<option value="save">-SAVE-
<option value="delete">-DELETE-
</SELECT>
or
<SELECT>
<option value="">Select a task:
<option value="update">-UPDATE-
<option value="save">-SAVE-
<option value="delete">-DELETE-
</SELECT>
g.
river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
Hi!
Regarding my problem..instead of using a blank the defualt values will appear on the drop down upon loading of the page....it is required that the drop down will only contain all valid values and not a blank....
Pls feel free to ask i u need some other clarifications...:-)
thanks
Meidi Novel
Greenhorn

Joined: Dec 13, 2002
Posts: 2
The problem i think is, u the page is not loaded with the default value..u are calling the same page on onChange event of the list..

i think this code will be useful
<select name="" onChange="..">
<option value="s">Save</option>
<option value="u">Update</option>
<option value="d">Delete</option>
</select>
.....
//as u know the default value is Save,the remaining program can be written with value="Save"...
String s = "Save";
if(request.getParameter("selectoption") != null)
s = "Save";
// so in the first case, the request.getParameter("selectoption") would be null, then the value of s will be default value ie, "Save"...

i hope this explanation helps u..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onchange event of drop down list - problem F1 pls
 
Similar Threads
drop down list problemt - Pls Help
How to create a set of interdependent drop down lists in struts 2.
getting values into the drop down list from database
How to retain selected content after post on same page
JSP + Ajax Combo box onChange event Pass Multiple Values