Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

onchange event of drop down list - problem F1 pls

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67671
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic