473,322 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to get values in the dropdown box

Hi all..
Please read this and help me.

My application needs to be like this.
The login page gets the username and in the second page there is a drop down box called project which gets the list of projects the person is involved in.. it fetches this data from the database. And then there is another drop down box called WBS code. After selecting a particular project, the wbs codes of the selected project are populated in that wbs code drop down. I'm able to get the project as a drop down box but i'm unable to fill the wbs codes after selection of the project.

Please give me the solution as soon as possible.

Thank you
Jun 19 '07 #1
5 2009
--------------------------------------------------------------------------------

Hi all..
Please read this and help me.

My application needs to be like this.
The login page gets the username and in the second page there is a drop down box called project which gets the list of projects the person is involved in.. it fetches this data from the database. And then there is another drop down box called WBS code. After selecting a particular project, the wbs codes of the selected project are populated in that wbs code drop down. I'm able to get the project as a drop down box but i'm unable to fill the wbs codes after selection of the project.

Please give me the solution as soon as possible.

Thank you
Jun 19 '07 #2
r035198x
13,262 8TB
Hi all..
Please read this and help me.

My application needs to be like this.
The login page gets the username and in the second page there is a drop down box called project which gets the list of projects the person is involved in.. it fetches this data from the database. And then there is another drop down box called WBS code. After selecting a particular project, the wbs codes of the selected project are populated in that wbs code drop down. I'm able to get the project as a drop down box but i'm unable to fill the wbs codes after selection of the project.

Please give me the solution as soon as possible.

Thank you
So the WBS codes are filled depending on the project selected?
This is a job for Ajax or even simple Javascript so I'll move it there.
Jun 19 '07 #3
acoder
16,027 Expert Mod 8TB
I assume you want to do this using AJAX. Post what code you have so far.
Jun 19 '07 #4
acoder
16,027 Expert Mod 8TB
Threads merged.
Jun 19 '07 #5
I assume you want to do this using AJAX. Post what code you have so far.
I'm not aware of AJAX. I'm sending you the code i have so far.. Please help me
Thank you in advance

[HTML]<%@ page contentType="text/html;charset=windows-1252"%>

<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.lang.Object.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>

<html><head>
<script language="JAVASCRIPT">
function save()
{
document.timesheetform.action = "Hide5.jsp?a=t";
document.timesheetform.submit();
}

function commit()
{
document.timesheetform.action = "Hide5.jsp?a=p";
document.timesheetform.submit();
}
</script>
</head>
<body>
[/html]
Expand|Select|Wrap|Line Numbers
  1. <Script>
  2.  
  3. var INPUT_NAME_PREFIX = 'inputName';
  4. var TABLE_NAME = 'tblSample';
  5. var headerRows;
  6. var i=0;
  7. window.onload=fillInRows;
  8.  
  9. function fillInRows()
  10. {
  11.   //timesheetform.entrydate.focus();
  12.     headerRows = document.getElementById(TABLE_NAME).rows.length;    
  13.     addRowToTable();
  14. }
  15.  
  16. function myRowObject(one, two, three, four,five,six,seven,eight)
  17. {
  18.     this.one = one; // text object
  19.     this.two = two; // input text object
  20.     this.three = three; // input checkbox object
  21.     this.four = four;
  22.     this.five = five;
  23.     this.six = six;
  24.     this.seven = seven;
  25.     this.eight = eight;
  26. }
  27.  
  28. function addRowToTable(val)
  29. {
  30.  
  31.   i++;
  32.     var tbl = document.getElementById(TABLE_NAME);
  33.     var nextRow = tbl.rows.length;
  34.     var iteration = nextRow - parseInt(headerRows) + parseInt(1);
  35.  
  36.     // add the row
  37.     var row = tbl.insertRow(nextRow);
  38.  
  39.  
  40.   // cell 0 - check box select delete
  41.     var cell0 = row.insertCell(0);
  42.     var cb = document.createElement('input');
  43.     cb.setAttribute('type', 'checkbox');
  44.     cb.setAttribute('name', INPUT_NAME_PREFIX + iteration);    
  45.     cell0.appendChild(cb);
  46.  
  47.     // cell 1 - select WBS code         
  48.  
  49.       var test = new Array();            
  50.       var cell1 = row.insertCell(1);            
  51.             for(var ii=0; ii<document.timesheetform.l.value; ii++)
  52.             {                
  53.                 test[ii]=document.getElementById("wbsname"+ii).value;            
  54.             }
  55.       var opt;
  56. var txt;
  57. var sel = document.createElement('select');
  58. sel.setAttribute("name","wbscode"+i);
  59. for(var ii=0; ii<document.timesheetform.l.value; ii++)
  60. {
  61. opt = document.createElement("option");
  62. opt.setAttribute("value",test[ii]);
  63. txt = document.createTextNode(test[ii]);
  64. opt.appendChild(txt);
  65. sel.appendChild(opt);
  66. }
  67. cell1.appendChild(sel);
  68.  
  69.      /* var abc="<select name='wbscode"+i+"'>";
  70.       for(var ii=0; ii<document.timesheetform.l.value; ii++)
  71.       {
  72.       abc+="<option value='"+ii+"'>"+test[ii]+"</option>";
  73.       }
  74.       abc+="</select>";        
  75.       cell1.innerHTML = abc; */
  76.  
  77.   // cell 2 - input text   Start Time
  78.     var cell2 = row.insertCell(2);
  79.     var txtInp = document.createElement('input');
  80.     txtInp.setAttribute('type', 'text');
  81.     txtInp.setAttribute("name","stime"+i);
  82.     txtInp.setAttribute('size', '10');
  83.     cell2.appendChild(txtInp);
  84.  /* txtInp.onactivate = function() { 
  85.     hrs.disabled=false;
  86.   hrs.value="";
  87.  
  88.   } ;*/
  89.   txtInp.onchange = function() { 
  90.     hrs.disabled=false;
  91.   //hrs.value=((Number(ehr)*60+Number(emn))-((Number(shr)*60)+Number(smn)));
  92.  
  93.   }
  94.  
  95.  
  96.     // cell 3 - Text End time
  97.     var cell3 = row.insertCell(3);
  98.     var btn = document.createElement('input');
  99.     btn.setAttribute('type', 'text');
  100.     btn.setAttribute('name', 'etime'+i);
  101.     btn.setAttribute('size', '10');    
  102.     cell3.appendChild(btn);
  103.   btn.onactivate = function() {   
  104.    // hrs.disabled=false;
  105.    // hrs.value="";  
  106.   if(txtInp.value=="")
  107.   {  alert("Enter Start Date");txtInp.focus();return false;   }
  108.   else if(txtInp.value.length>5 || txtInp.value.length<5)
  109.   {alert("Please follow the format hr:mn");txtInp.focus();return false;}  
  110.   return false;   
  111.   } ;
  112.   btn.onchange = function() {  
  113.     hrs.focus();return false;
  114.   //hrs.value=((Number(ehr)*60+Number(emn))-((Number(shr)*60)+Number(smn)));
  115.  
  116.   }
  117.  
  118.  
  119.         // cell 4- text hrs worked
  120.       var cell4 = row.insertCell(4);
  121.     var hrs = document.createElement('input');
  122.     hrs.setAttribute('type', 'text');
  123.   hrs.setAttribute('name', 'hrswkd'+i);
  124.   hrs.setAttribute('size', '10');
  125.   hrs.setAttribute('readOnly', 'true');
  126.     cell4.appendChild(hrs);   
  127.   hrs.onactivate = function() { 
  128.  
  129.   if(btn.value=="")
  130.   {  alert("Enter End Date");btn.focus();return false;   }
  131.   else if(btn.value.length>5 || btn.value.length<5)
  132.   {alert("Please follow the format hr:mn");btn.focus();return false;}
  133.  else{
  134.   var ehr=btn.value.substring(0,2);var emn=btn.value.substring(3,5);
  135.   var shr=txtInp.value.substring(0,2);var smn=txtInp.value.substring(3,5);
  136.   if(smn>59)
  137.   {alert("Error in minutes entered");txtInp.focus();return false;}
  138.   else if(emn>59)
  139.   {alert("Error in minutes entered");btn.focus();return false;}
  140.   if(shr>23)
  141.   {alert("Error in hours entered");txtInp.focus();return false;}
  142.   else if(ehr>23)
  143.   {alert("Error in hours entered");btn.focus();return false;}
  144.   if(shr>ehr)
  145.   {alert("Start time cannot be greater than end time");btn.focus();return false;}
  146.  
  147.   else if(ehr==shr)
  148.   {  if(emn<smn){alert("Start time cannot be greater than end time");btn.focus();return false;}  }
  149.   }
  150.   var xx=((Number(ehr)*60+Number(emn))-((Number(shr)*60)+Number(smn)));
  151.   if(xx%15>0)
  152.   hrs.value=xx+(15-(xx%15));
  153.   else hrs.value=xx;
  154.   //hrs.disabled=true;
  155.   return false; 
  156.   }
  157.   ;
  158.  
  159.     // cell 5 -select activity
  160.     var cell5 = row.insertCell(5);
  161.     var cb2 = document.createElement('select');
  162.       cb2.setAttribute("name","activity"+i);
  163.       secondOpt1=document.createElement("option");
  164.       secondOpt1.setAttribute("id","design");
  165.       secondOpt1.setAttribute("value","Design");
  166.       secondOpt1.appendChild(document.createTextNode("Design"));
  167.       secondOpt2=document.createElement("option");
  168.       secondOpt2.setAttribute("id","implementation");
  169.       secondOpt2.setAttribute("value","Implementation");
  170.       secondOpt2.appendChild(document.createTextNode("Implementation"));
  171.       secondOpt3=document.createElement("option");
  172.       secondOpt3.setAttribute("id","testing");
  173.       secondOpt3.setAttribute("value","Testing");
  174.       secondOpt3.appendChild(document.createTextNode("Testing"));
  175.       cb2.appendChild(secondOpt1);
  176.       cb2.appendChild(secondOpt2);
  177.       cb2.appendChild(secondOpt3);    
  178.         cell5.appendChild(cb2);
  179.  
  180.  // cell 6 - select activity type
  181.     var cell6 = row.insertCell(6);
  182.     var cb3 = document.createElement('select');
  183.   cb3.setAttribute("name","activitytype"+i);
  184.   Opt1=document.createElement("option");
  185.   Opt1.setAttribute("id","f");
  186.   Opt1.setAttribute("value","f");
  187.   Opt1.appendChild(document.createTextNode("Fresh"));
  188.    Opt2=document.createElement("option");
  189.    Opt2.setAttribute("id","r");
  190.    Opt2.setAttribute("value","r");
  191.    Opt2.appendChild(document.createTextNode("Rework"));
  192.     Opt3=document.createElement("option");
  193.     Opt3.setAttribute("id","R");
  194.     Opt3.setAttribute("value","R");
  195.     Opt3.appendChild(document.createTextNode("Review"));
  196.      Opt4=document.createElement("option");
  197.      Opt4.setAttribute("id","c");
  198.      Opt4.setAttribute("value","c");
  199.      Opt4.appendChild(document.createTextNode("Change Request"));
  200.      cb3.appendChild(Opt1);
  201.      cb3.appendChild(Opt2);
  202.      cb3.appendChild(Opt3);
  203.      cb3.appendChild(Opt4);
  204.       cell6.appendChild(cb3); 
  205.  
  206. // cell 7 - textarea work details
  207.     var cell7 = row.insertCell(7);
  208.     var cb4 = document.createElement('textarea');
  209.     //cb2.setAttribute('type', 'textarea');
  210.   cb4.setAttribute('cols', '20');
  211.   cb4.setAttribute('name', 'wdetails'+i);
  212.   //cb.setAttribute('option', 'def');
  213.     cell7.appendChild(cb4);
  214.  
  215.   var cell8 = row.insertCell(8);
  216.     var cb5 = document.createElement('select');
  217.   cb5.setAttribute("name","status"+i);
  218.   Opt11=document.createElement("option");
  219.   Opt11.setAttribute("id","f");
  220.   Opt11.setAttribute("value","C");
  221.   Opt11.appendChild(document.createTextNode("Completed"));
  222.    Opt12=document.createElement("option");
  223.    Opt12.setAttribute("id","r");
  224.    Opt12.setAttribute("value","P");
  225.    Opt12.appendChild(document.createTextNode("Pending"));
  226.     Opt13=document.createElement("option");
  227.     Opt13.setAttribute("id","R");
  228.     Opt13.setAttribute("value","I");
  229.     Opt13.appendChild(document.createTextNode("In Progress"));     
  230.      cb5.appendChild(Opt11);
  231.      cb5.appendChild(Opt12);
  232.      cb5.appendChild(Opt13);     
  233.       cell8.appendChild(cb5);
  234.  
  235.     row.myRow = new myRowObject(cb,txtInp,btn,hrs,cb2,cb3,cb4,cb5); 
  236.   document.timesheetform.iii.value=i;
  237. }
  238.  
  239. // CONFIG: this entire function is affected by myRowObject settings // If there isn't a checkbox in your row, then this function can't be used.
  240. function deleteChecked()
  241. {
  242.     var checkedObjArray = new Array();
  243.     var cCount = 0;
  244.  
  245.     var tbl = document.getElementById(TABLE_NAME);
  246.     for (var i=0; i<tbl.rows.length; i++) {
  247.         if (tbl.rows[i].myRow && tbl.rows[i].myRow.one.getAttribute('type') == 'checkbox' && tbl.rows[i].myRow.one.checked) {
  248.             checkedObjArray[cCount] = tbl.rows[i];
  249.             cCount++;
  250.         }
  251.     }
  252.     if (checkedObjArray.length > 0 ) {
  253.         var rIndex = checkedObjArray[0].rowIndex;
  254.         deleteRows(checkedObjArray);
  255.         reorderRows(tbl, rIndex);
  256.     }
  257. }
  258.  
  259. function reorderRows(tbl, startingIndex) {
  260.     if (tbl.rows[startingIndex]) {
  261.         var count = startingIndex;
  262.         for (var i=startingIndex; i<tbl.rows.length; i++) {
  263.  
  264.             // CONFIG: next line is affected by myRowObject settings
  265.             tbl.rows[i].myRow.one.data = count; // text
  266.  
  267.             // CONFIG: next line is affected by myRowObject settings
  268.             tbl.rows[i].myRow.two.name = INPUT_NAME_PREFIX + count; // input text
  269.  
  270.             // CONFIG: next line is affected by myRowObject settings
  271.             //var tempVal = tbl.rows[i].myRow.two.value.split(' '); // for debug purposes
  272.             //tbl.rows[i].myRow.two.value = count + ' was' + tempVal[0]; // for debug purposes
  273.             count++;
  274.         }
  275.     }
  276. }
  277.  
  278. function deleteRows(rowObjArray)
  279. {
  280.     for (var i=0; i<rowObjArray.length; i++) {
  281.         var rIndex = rowObjArray[i].rowIndex;
  282.         rowObjArray[i].parentNode.deleteRow(rIndex);
  283.     }
  284. }
  285.  
  286. function openInNewWindow(frm)
  287. {
  288.     // open a blank window
  289.     var aWindow = window.open('', 'TableAddRow2NewWindow',
  290.     'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
  291.  
  292.     // set the target to the blank window
  293.     frm.target = 'TableAddRow2NewWindow';
  294.  
  295.     // submit
  296.     frm.submit();
  297. }
  298. </Script>
[html]<script src="Timesheetvalidate.js">
</script>
<script src="Editdata.js">
</script>
</head><body>
<center><h2>Time Sheet Details </h2></center>
<%if(session.getAttribute ("emp_name").equals("admini"))
{ %>
<div style="padding-left:600;font-size=10pt; FONT-FAMILY:arial;">
<a href="EmpCreate.jsp">Create User</a>&nbsp;&nbsp;&nbsp;
<a href="ProjectDetails.jsp">Project Details</a>&nbsp;&nbsp;&nbsp;
<a href="ChangePass.jsp">Change Password</a>&nbsp;&nbsp;&nbsp;
<a href="Logout.jsp">Logout</a>&nbsp;&nbsp;&nbsp;
</div>
<% }
else
{%>
<div style="padding-left:800;font-size=10pt; FONT-FAMILY:arial;">
<a href="ChangePass.jsp">Change Password</a>&nbsp;&nbsp;&nbsp;
<a href="Logout.jsp">Logout</a>&nbsp;&nbsp;&nbsp;
</div>
<div style="padding-left:800;font-size=10pt; FONT-FAMILY:arial;">
<a href="#" onclick="javascript:edit()">Edit Temporararily Saved</a>
</div>
<% }%>
<form action="#" method="post" name="timesheetform" onSubmit="return checkDate(this);">

<table class="noborder" align="center">
<tr>
<td >Name</td>
<td >
<input type="text" name="T1" readonly size="25" value="<%=session.getAttribute("emp_name")%>">
</td>
</tr>
<%
Vector prjname=new Vector();
Vector prjid=new Vector();
Vector wbss=new Vector();
int i=0;
int vari=0;
String empid=(String)session.getAttribute("emp_ID");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con1 = DriverManager.getConnection("jdbc:odbc:sujay","tim esheet","timesheet");
Statement st= con1.createStatement();
ResultSet rs = st.executeQuery("select ts_project.prj_name,ts_project.prj_id from TS_PROJECT,ts_projectteam where ts_project.prj_id=ts_projectteam.prj_id and ts_projectteam.emp_id='"+empid+"'");
while(rs.next())
{
prjname.add(vari,rs.getString("prj_name"));
prjid.add(vari,rs.getString("prj_id"));

}
session.setAttribute("prj_ID",prjid);
ResultSet rs1 = st.executeQuery("select wbs_id from ts_wbs where prj_id='"+prjid+"'");
while(rs1.next())
{
wbss.add(i,rs1.getString(1));
i++;
}
int len=wbss.size();
%><input type="hidden" name = l size="25" value=<%=len%> >
<tr>
<td>Project</td>
<td> <select>
<% for(int varj=0; varj<=vari; varj++){%>
<option><%=prjname.elementAt(varj)%></option>
<%}%><option selected>Default</option></select>

</td>
</tr>
</table>
<% for(int k=0;k<len;k++){ %>
<input type="hidden" name = "wbsname<%=k%>" size="20" value=<%=wbss.elementAt(k)%> disabled>
<%}%><br><br><br>
<center>
<table border="1" id="tblSample" class="sample">
<tr>
<th >Select</th>
<th >WBS</th>
<th >Start Time</th>
<th >End Time</th>
<th >Mins Worked</th>
<th >Activity</th>
<th >Activity Type</th>
<th >Detail of Work</th>
<th >Status</th>
</tr>
</table><br><br><br><br>
<input type="hidden" name="iii">

<input type="button" value="Add" onclick="addRowToTable();" class="button" />
<input type="button" value="Save" class="button" onClick="save()"/>
<input type="button" value="Commit" class="button" onClick="commit()"/>
<input type="button" value="Delete Selected" onclick="deleteChecked();" />
<input type="button" value="Exit" onclick="window.close();" class="button"/>
</center> </form> </html>[/HTML]
Jun 20 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Noyb | last post by:
I have a page with two drop-downs, each listing the same employee names and their id's as the values. So they look like: <select name="selection_1"> <option value="12">Curly</option> <option...
1
by: Les Juby | last post by:
Simple problem that's stumping me at present.! We have created a data capture form in Access 97 which uses a dropdown list which has been populated from a table. The dropdown list displays the...
0
by: Jeff | last post by:
After I bind the repeater control in the form_load event, it builds multiple lines based on the number of rows in the dataset. In the repeater control, I have a textbox and a dropdown list box. ...
1
by: oj | last post by:
Could anyone provide some approaches that are used to cache dropdown list control values to share globally beteween all users? Currently, each time a page is loaded all the dropdown values for each...
0
by: Matthias S. | last post by:
Hi there, first of all, sorry for the lengthy post, but restrictions in my languages skills and the nature of the problem account for it. I've got the following situation: I'm creating a...
0
by: Kay | last post by:
Hello, I have developed a web custom control, I want one of the properties of the control to appear as a dropdown list so the user can select from the list. My question is: how do I define an...
0
by: Kay | last post by:
Hello, I have developed a web custom control, I want one of the properties of the control to appear as a dropdown list so the user can select from the list. My question is: how do I define an...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
10
by: LionsDome | last post by:
Hello, I have a vb.net page which a bunch of checkboxes. A user can select a checkbox(s) and hit the submit button to store those values in a SQL Server table. This works fine with no problem...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.