• Post Reply Bookmark Topic Watch Topic
  • New Topic

Related to Javascripet SELECT object  RSS feed

 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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
 
Arun Prasad Namasivayam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!