• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Related to Javascripet SELECT object

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have three select objects in one edit.jsp page. one for date anothers for month and year.
In display.jsp i am displaying date,month,year from database. in this page i have an option edit. if i click edit button the control goes to edit.jsp page.
there i want to display three select objects which contains values accordingly.
when i click edit button on display.jsp page, i want to display in edit.jsp ,the object of Date must display the date which is comes from display.jsp. month and year should display the values which are from display.jsp.
how to do that ? right now if i click the edit button, in edit.jsp page has displayed the date and month and year value starts from
01 JAN 2000.
any one knows solution pls let me know.

thanks
saran
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll explain the overall logic and syntax,
Let us assume that month value u need to set in the select list is stored in the jsp variable "dbMonth".
JSP Variable - dbMonth - Month value
HTML Form Name - frmForm - Form Name
HTML Form - selMonth - Month select list
so if above is the example case so for that im goin to explain you how to use javascript and to set the select list to the corresponding month.
the following code is assumed that the select list is populated with the date values.
<script>
for(i=0;i<document.frmForm.selMonth.length;i++)
{
if(document.frmForm.selMonth.options[i].value == '<%=dbMonth%>')
{
document.frmForm.selMonth.options[i].selected = true;
break;
}
}
</script>
like above you need to do for the select list to load with the value.
keep smiling
arun
 
it's a teeny, tiny, wafer thin ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic