This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes drop down list problemt - Pls Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "drop down list problemt - Pls Help" Watch "drop down list problemt - Pls Help" New topic
Author

drop down list problemt - Pls Help

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
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
can you give us the code??
river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
below are the code:
As u can see the values are dynamic:
and the defualt values defend on the
variable sortType (w/c is also one of the dropDown list values)
<select name="carrierValue" onchange="javascript:submitSort()">
<% for(int k=0;k<sortClassVector.size();k++)
{ String carrierDesc = new String((String)sortClassVector.get(k));
String carrierVal = new String((String) sortClassVector.get(++k));%>
<option value="<%= carrierVal %>"
<%if ((sortType == carrierVal) || (sortType.trim().equals(carrierVal.trim()))) {%>
SELECTED ><%=carrierDesc%>
<%} else {%> ><%=carrierDesc%></option>
<%}%>
<%}%>
</select>
Thanks in advance
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
handle the select onclick event,remove the space between on and click
<select on click=handleSelect()>
river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
I'll try this and I keep u updated...thanks a lot in advance
river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
Is this correct...cause it seems not working nothing happens when I click the dropdwon list

<select name="carrierValue" on click="handleSelect()">

handleSelect() is a javascript functions right.?
please advise
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
Make sure you REMOVE THE SPACE -> "ON CLICK"
The space between on and click must be removed.
The space is only in there because the java ranch bbs software gets upset about on click being one work.
I did the following and it seems to works ok
remember to remove the space
on click=handleSelect
river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
Hi!
I try to adopt the code ...but its not working with me....when I click the drop down list...nothings works no message box appears.....does it varries in the browser (IE/NET) and its version...? any onter idea...?
Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can just put a button beside it and perfom the action on click of the button.
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
This is an extremely simple code example.I ran in ie 5.5 and Mozilla 6.2.When you make a simple mistake in javascript you do not get an error msg
for example let's say the function call name does not match the function name you would get a silent failure like the one you describe.
that's it you are on your own
river down
Greenhorn

Joined: Dec 11, 2002
Posts: 21
I try to check it against the browser version....and I will try any possible solution then...I'll keep u posted....
Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you can try to use onblur="asdasdsa"
 
 
subject: drop down list problemt - Pls Help
 
Similar Threads
How to retain selected content after post on same page
passing parameters
How to create a set of interdependent drop down lists in struts 2.
onchange event of drop down list - problem F1 pls
setting a default value for a drop-down