getting the column name - sql

I've the below html.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form name="new" method="post" action="GetR.jsp">
<div class="Main">
<table width="200" border="1">
<tr>
<td>Units</td>
<td><input type="text" name="Units" id="Units"></td>
</tr>
<tr>
<td>Product Type</td>
<td><input type="text" name="ProdT" id="ProdT"></td>
</tr>
<tr>
<td>Hours</td>
<td><input type="text" name="hours" id="hours"></td>
</tr>
<tr>
<td colspan="2"><input name="submit" type="submit" id="submit" value="Submit"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
and the below data base table
here actually when the user enters the number of units and hours and product type(product type is same as database table name) based on the input, the output should be the column names(whether it is achieved, exceeded or far exceeded) . please let me know how can i write a query for it.
for example the given row.
we entered the units as 1, and if the hours is 8(4.1hrs-8hrs), it should show No.of.Hours for Achieved, if hours is 4(2.1hrs-4hrs) it should show Exceeded and if 2(below 2 hrs) it should show Far-Exceeded.
Thanks

Related

SQL Query on jsp file using Text Box Search and button

I have a difficulty in the search(select sql statement). How to put the value I inputed in the text box and use it in the sql query
so that I can search the department name regarding to the value I inserted.
I don't know the right Query for this "SELECT * FROM department where department_name ='"%search%"'"
Here is my jsp file below:
<%# page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
/head>
<body>
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/department"
user="root" password="root"/>
<sql:query dataSource="${snapshot}" var="sql">
SELECT * from department;
<!-- SELECT * FROM department where department_name ='"%search%"'-->
</sql:query>
<FORM NAME="form1" METHOD="POST">
<input type="text" name="search"/>
<INPUT TYPE="BUTTON" VALUE="Button 1">
</FORM><br>
<table border=1>
<thead>
<tr>
<th>department Id</th>
<th>department Name</th>
<th colspan=1>Action</th>
</tr>
</thead>
<tbody>
<c:forEach var="user" items="${sql.rows}">
<tr>
<td><c:out value="${user.department_id}" /></td>
<td><c:out value="${user.department_name}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
In the fist, insert paramerer into you SQL query
<sql:query dataSource="${snapshot}" var="sql">
SELECT * from department WHERE department_name = <%= request.getParameter("query") %>;
</sql:query>
Change method to METHOD="GET" and
<input type="text" name="query"/>
<INPUT TYPE="submit">
When you click button, url was like
http://hostname.com/mywebapp/mypage.jsp?query=John+Smith

Any Dijit component is rendered as TextField

Please find my code which intents to develop a Form. Help me in understanding why the CheckBox and NumberSpinner are rendered as TextFields.
I have imported all the required classes and dojo config attribute is configured properly
<%# taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%# taglib prefix="fmt" uri=`enter code here`"http://java.sun.com/jstl/fmt" %>
<%#include file="/webclient/admin/jspf/NotificationOperations.jspf" %>
<!-- load dojo and provide config via data attribute -->
<script type="text/javascript" src="/webclient/map/js/dojo/dojo.js" data-dojo-config="parseOnLoad: true"></script>
<script>
require([
"dojo/parser",
"dijit/form/CheckBox",
"dijit/form/NumberSpinner",
"dojo/domReady!"
], function(parser){
parser.parse();
});
</script>
<%#include file="/webclient/common/jspf/jsUtility.jspf" %>
<html>
<head>
<body class="claro">
<style>
#import "/webclient/common/js/dojo/dgrid/css/skins/claro.css";
h2 {
margin: 12px;
}
.heading {
font-weight: bold;
padding-bottom: 0.25em;
}
.ui-widget{
margin: 10px;
}
</style>
<table width="100%" height="100%">
<tr><td>
<div id="DomainMapContainer" >
<tr class="spacer"><td> </td></tr>
<tr><td>
<form id="addProfile" data-dojo-type="dijit/form/Form" data-dojo-props='encType:"multipart/form-data", action:"/prov/createRFC2544TestProfile.do?action=createRFC2544TestProfile", method:"POST", target:"formSubmitIframe"'>
<table>
<tr>
<td><label for="profileName">Profile Name</label></td>
<td>
<input data-dojo-type="dijit/form/TextBox" data-dojo-props='id:"profileName", name:"profileName", required:"true"'/>
</td>
</tr>
<tr>
<td><label for="comments">Comments</label></td>
<td>
<input data-dojo-type="dijit/form/TextArea" data-dojo-props='id:"comments", name:"comments", rows:"5", cols:"40"'/>
</td>
</tr>
<tr>
<td><label for="frameSize">Frame Size</label></td>
<td>
<table>
<tr>
<td><label for="cb_1"><input data-dojo-type="dijit/form/CheckBox" id="cb_1" name="cb_1" value="64" checked/> 64</label></td>
<td><label for="cb_2"><input data-dojo-type="dijit/form/CheckBox" id="cb_2" name="cb_2" value="128"/> 128</label></td>
</table>
</td>
</tr>
</table>
<fieldset>
<legend><label> Throughput Test</label></legend>
<table>
<tr>
<td><label for="tTestDuration">Test Duration</label></td>
<td><input data-dojo-type="dijit/form/NumberSpinner" id="tTestDuration" value="60" data-dojo-props="smallDelta:1, constraints:{min:1,max:600,places:0}" name="tTestDuration"/>(Seconds)</td>
</tr>
<tr>
<td><label for="tTestMinFrameRate">Minimum Frame Rate</label></td>
<td><input data-dojo-type="dijit/form/NumberSpinner" id="tTestMinFrameRate" value="0" data-dojo-props="smallDelta:1, constraints:{min:1,max:10000,places:0}" name="tTestMinFrameRate"/>(Mbps)</td>
</tr>
<tr>
<td><label for="tTestMaxFrameRate">Maximum Frame Rate</label></td>
<td><input data-dojo-type="dijit/form/NumberSpinner" id="tTestMaxFrameRate" value="100" data-dojo-props="smallDelta:1, constraints:{min:1,max:10000,places:0}" name="tTestMaxFrameRate"/>(Mbps)</td>
</tr>
<tr>
<td><label for="tTestStepSize">Step Size</label></td>
<td><input data-dojo-type="dijit/form/NumberSpinner" id="tTestStepSize" value="5" data-dojo-props="smallDelta:1, constraints:{min:1,max:100,places:0}" name="tTestStepSize"/>(Mbps)</td>
</tr>
<tr>
<td><label for="tTestAcceptableLoss">Step Size</label></td>
<td><input data-dojo-type="dijit/form/NumberSpinner" id="tTestAcceptableLoss" value="0" data-dojo-props="smallDelta:0.1, constraints:{min:0,max:10,places:0}" name="tTestAcceptableLoss"/>(%)</td>
</tr>
</table>
</fieldset>
</form>
</td></tr>
</div>
</td></tr>
</table>
</body>
</head>
</html>
I'm seeing a few things here, first of all you're missing a closing </tr> tag when you close the "frame size" table. I suppose that it won't cause errors, but you can never be too sure.
You're also closing your </head> tag at the bottom of the page. You should close it before the <body> starts.
Then the real problem is that your widgets are not working because there are errors while parsing your HTML. The cause of the error is the "comments" text area. The correct module name you should use is dijit/form/Textarea, so the "a" of area should be in lowercase.
Besides that, you should also add the dijit/form/Textarea module to your list of modules (in your require() block).
If you did all that it should work, as you can see in this fiddle: http://jsfiddle.net/9U5AB/

How to place a table within a table on top

I'm fighting with bad support of html clients for CSS and I need to do a email template with table layout.
I just can't place and align tables within tables correctly. I tried it with valign etc. but this doesn't work...
How can I place one table within another table on top and in the center?
To illustrate I've posted this fiddle:
http://jsfiddle.net/eabJh/1/
The <td >Another nested table</td> is in center position but not on top but in the middle.
Here is my html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body style="background-color: black">
<table background="http://i3.mirror.co.uk/incoming/article276604.ece/ALTERNATES/s615/tweet-that-ricky-gervais-jibe-at-mongs-pic-twitter-com-rickygervais-132840776.jpg" width="810" border="20" bordercolor="white" style="border-style:solid; border-spacing:0px; border-collapse:collapse">
<tr style="height:400px">
<td>test
<table width="380" cellspacing="0" cellpadding="2" align="center" border="0">
<tr>
<td >Another nested table</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
</html>
Updated Fiddle
Use valign = "top":
<td valign = "top">test
<table width="380" cellspacing="0" cellpadding="2" align="center" border="0">
<tr>
<td>Another nested table</td>
</tr>
</table>
</td>

Dojo login form - how to send post method

I have downloaded Dojo login form. What should I change so that when I click on the Login button, I send a POST request with parameters to index.php?
dojo.require("dijit.form.DropDownButton");
dojo.require("dijit.TooltipDialog");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/resources/dojo.css" rel="stylesheet" />
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<body class="claro">
<div dojoType="dijit.form.DropDownButton" class="soria" style="float:right;">
<span>Login</span>
<div dojoType="dijit.TooltipDialog" id="dialog1"
title="Login Form" execute="checkPw(arguments[0]);">
<table>
<tr>
<td><label for="name" title="User name">
Username</label></td>
<td><input dojoType="dijit.form.TextBox"
type="text" name="oldpw"></td>
</tr>
<tr>
<td><label for="loc">Password: </label></td>
<td><input dojoType="dijit.form.TextBox"
type="password" name="newpw"></td>
</tr>
<tr>
<td colspan="2" align="center">
<button dojoType="dijit.form.Button"
type="submit">Login</button></td>
</tr>
</table>
</div>
</div>
You need to add form tag with action
<div dojoType="dijit.form.DropDownButton" class="soria" style="float:right;">
<span>Login</span>
<div dojoType="dijit.TooltipDialog" id="dialog1"
title="Login Form" execute="checkPw(arguments[0]);">
<form id="login_form" method="POST" action="index.php">
<table>
<tr>
<td><label for="name" title="User name">
Username</label></td>
<td><input dojoType="dijit.form.TextBox"
type="text" name="oldpw"></td>
</tr>
<tr>
<td><label for="loc">Password: </label></td>
<td><input dojoType="dijit.form.TextBox"
type="password" name="newpw"></td>
</tr>
<tr>
<td colspan="2" align="center">
<button dojoType="dijit.form.Button"
type="submit">Login</button></td>
</tr>
</table>
</form>
</div>
</div>

How do I insert value into labels using dojo

I am trying to dynamically insert the values in the labels which I will hide from sighted users but will be read by screen readers for visually impaired users that are displayed in the columns. How can I accomplish this using dojo?
<html>
<head>
<title>Dojo Labels</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/dojo/1.3.2/dojo/dojo.xd.js"></script>
<style type="text/css">
.style1
{
width: 154px;
}
</style>
</head>
<body>
<table style="width: 51%; height: 204px;">
<tr>
<td class="style1">
<input id="Checkbox1" type="checkbox" />
<label for="Checkbox1"></label>
</td>
<td>
John
</td>
<td>
Doe
</td>
</tr>
<tr>
<td class="style1">
<input id="Checkbox2" type="checkbox" />
<label for="Checkbox2"></label>
</td>
<td>
Jane
</td>
<td>
Doe
</td>
</tr>
<tr>
<td class="style1">
<input id="Checkbox3" type="checkbox" />
<label for="Checkbox3"></label>
</td>
<td>
John
</td>
<td>
Smith
</td>
</tr>
</table>
</body>
</html>
If you just need to dynamically change label then you can try this:
dojo.query("label[for=Checkbox1]")[0].innerHTML = "text";
But if you need logic to detect if it is a screen reader or a browser then I cannot help. But you probably could always render label with text just add style display:none;
<label for="Checkbox2" style="display:none;">text</label>
not exactly sure if I understand exactly what you are doing, but dojo provides a method that allows you to modify a DOM node's attribute values. It's called dojo.attr()
Maybe this one will help.
To get label content : dijit.byId("btnButtonName").get("label")=="SomeName");
To set label content : dijit.byId("btnButtonName").set("label", "SomeName");