• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

drop down list problemt - Pls Help

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you give us the code??
 
river down
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
handle the select onclick event,remove the space between on and click
<select on click=handleSelect()>
 
river down
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try this and I keep u updated...thanks a lot in advance
 
river down
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just put a button beside it and perfom the action on click of the button.
 
Charlie Sturman
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can try to use onblur="asdasdsa"
 
It's just a flesh wound! Or a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic