Member Avatar

How to display text string with Javascript on screen? This is my test page: [CODE]<html> test <script type="text/javascript"> docwrite(1); document.write('hi'); docwrite('hello'); </script> docwrite(2); <script type="text/javascript"> function docwrite(x) { document.write(x); } </script> </html> [/CODE] I saw only "test docwrite(2);". I want to see "test 1 hi hello docwrite(2);" with " 1 hi hello" coming from Javascript. How to do that?

Member Avatar
0
33
Member Avatar

This SQL operation will get the desired Proposal_ID. [CODE]SELECT P.Proposal_ID, AVG(c.Task_Good_Idea) AS Average FROM proposals P, proposal_appraisal c LEFT OUTER JOIN users b ON (c.Evaluator_ID = b.User_ID) LEFT OUTER JOIN submission_status d ON (c.Primary_Evaluation_Status_ID = d.submission_status_ID) WHERE (P.Proposal_ID = c.Proposal_ID) AND P.Proposal_ID >= 931 AND d.Submission_Status_ID = 2 GROUP BY Proposal_ID HAVING Average >=25 [/CODE] How to modify the following SQL operation so that only desired Proposal_ID are used? [CODE]select cfp_Id, P.proposal_id, P.institution_Name, sum(P.Task_Good_Idea + P.Task_Involve_Youth + P.Task_Involve_Partnerships + P.Task_Exploit_Digital_Medium + P.Task_Value_For_Money + P.Task_Theme + P.Task_Skills_Development + P.Task_LOC_Curriculum) as Task_Good_Idea from proposals P group by P.proposal_ID having (Task_Good_Idea >= 25) …

Member Avatar
0
3
Member Avatar

Given the following two SQL operations: [CODE]select prod_Id, P.proposal_id, P.institution_Name from proposals P group by P.proposal_ID having mark >= 50 order by P.proposal_id desc select prod_id, P.proposal_id, PA.evaluator_ID, U.user_Given_Name, U.user_surname from users U, proposals P LEFT outer JOIN proposal_appraisal PA ON (P.proposal_Id = PA.proposal_id) where PA.evaluator_ID = U.user_id group by prod_id, PA.evaluator_ID order by PA.proposal_ID, U.user_ID desc [/CODE] How to modify the following SQL operation so that prod_Id will be selected in addition to the existing columns being selected: [CODE]select PA.proposal_id, PA.evaluator_ID, PA.Primary_Evaluation_Status_ID, PA.Secondary_Evaluation_Status_ID, U.user_Given_Name, U.user_surname, from users U, proposal_appraisal PA where PA.evaluator_ID = U.user_id group by PA.proposal_id, PA.evaluator_ID order …

Member Avatar
0
3
Member Avatar

How to calculate an average and use that average to select some data? e.g. for this query and its result. [CODE]select Proposal_ID, Mark, AVG(Mark) AS Average from proposal where (Proposal_ID >= 931) GROUP BY Proposal_ID 931 20 22.2222 935 30 22.2222 936 30 21.1111 967 30 25.5556 968 30 20.0000 994 30 19.4444 995 20 15.5556 1010 30 17.7778 1011 20 17.5000 1015 20 17.7778 1018 20 17.7778 1020 30 18.8889 1049 30 20.0000 1050 30 22.5000 1051 0 15.5556 1052 10 17.7778 1053 30 23.3333 [/CODE] How to refine the query so that after the average is calculated, then …

Member Avatar
0
2
Member Avatar

I print the following webpage with Firefox & Chrome: [url]http://en.wikipedia.org/wiki/Final_(Java[/url]) Both hardcopies of the long line "public static final double PI = 3.141592653589793; // this is essentially a constant" is cut off. i.e. the line does not wrap around. Both Firefox & Chrome display that line on screen in one line without any cut off nor wrap around. How to make the hardcopy of that long line without any chop off? I do not want to reduce the font size of the web page.

0
1
Member Avatar

I want to optimize the following small integer program in speed. My g++ compiler version is 4.3.4 on 32 bit linux. Please suggest or comment the following ideas. Some ideas are: 1. use compile flag such as -O3 2. rewrite the bigger function with function object [CODE]#include <algorithm> #include <cstdlib> // for abs() using namespace std; const int N = 50; const int D = 20; bool bigger (int i) { return abs(i) >= D; } int main() { int seq[N], diff[N]; // initialize seq // ... adjacent_difference(seq, seq + N, diff); int count = count_if(diff + 1, diff + …

Member Avatar
0
6
Member Avatar

Pressing the enter key of the following page (created by JSP) submit page more than once. Both alert popup boxes appear as expected: alert('i ' + i + ' elem[i].checked ' + elem[i].checked); alert('alarmgroup ' + alarmgroup + ' rowsPerPage ' + rowsPerPage); appear. However, then this alert appear again, which is unexpected: alert('i ' + i + ' elem[i].checked ' + elem[i].checked); but alert('alarmgroup ' + alarmgroup + ' rowsPerPage ' + rowsPerPage); do not appear. [CODE]<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" …

Member Avatar
0
2
Member Avatar

Pressing the enter key at the jsp page receive extra invalid data at the ProdController.java. The alertgroupStr receive "unack" as expected. However, I do not understand why alertgroupStr receive the extra invalid "null" later. Debug log: 11:14:52,187 DEBUG com.systems.monitoring.war.ProdController:54 - alertgroupStr unack ... 11:14:52,187 DEBUG com.systems.monitoring.war.ProdController:54 - alertgroupStr null ProdController.java: [code] @Override public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { String alertgroupStr = request.getParameter("alertgroup"); logger.debug("alertgroupStr " + alertgroupStr); [/code] Jsp page: [code]<?xml version="1.0" encoding="UTF-8" ?> <%@ include file="/WEB-INF/jsp/includeTaglibs.jsp"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" media="all" href="/static/css/style.css" …

0
1
Member Avatar

My javascript function setHw is not called by pressing the return key in all of the following pages. Please help. [CODE]<div id="rowPerPageDiv"> <form name="tagform" action="Hw.htm" method="post"> <input type="hidden" name="currPage" value="0"/> Rows Per Page<input type="text" name="rowsPerPage" id="rowsPerPage" value="20" onsubmit="return setHw()"/> <input type="button" value="Apply" onClick="setHw()"><br> </form> </div>[/CODE] [CODE]<div id="rowPerPageDiv"> <form name="tagform"> <input type="hidden" name="currPage" value="0"/> Rows Per Page<input type="text" name="rowsPerPage" id="rowsPerPage" value="20" onsubmit="return setHw()"/> <input type="button" value="Apply" onClick="setHw()"><br> </form> </div> [/CODE]

Member Avatar
0
3
Member Avatar

I want to implement JavaScript Internationalization. However, JavaScript does not have the property file mechanism (which is available in Java). I am thinking of using the Java property file mechanism in Javascript. Is it possible? I had implemented Java Internationalization with the Spring framework message. e.g. [CODE]<spring:message code="menu.administration"/>[/CODE] How do I use that in Javascript? All of the following codes had 'code cannot be resolved' parsing error in JSP. [CODE]<script type="text/javascript"> var confirmDeleteStr = '<%= spring:message code="account.confirmDelete" %>'; var confirmDeleteStr = 'spring:message code="account.confirmDelete"'; </script>[/CODE]

0
1
Member Avatar

My program should display '*' when entering a password to a text box by a user. How to do that?

Member Avatar
0
5
Member Avatar

How do I recursively remove all the directories and files which begin with '.'? My test program rmdir.py does not do the job yet. Please help. Code: #!c:/Python31/python.exe -u import os from shutil import * root = "C:\\test\\com.comp.hw.prod.proj.war\\bin" for curdir, dirs, files in os.walk(root): print (curdir) print (dirs) for d in dirs: print ("d " + d) if d.startswith('.'): print ("dotd " + os.path.join(curdir, d)) rmtree(os.path.join(curdir, d)) C:\python>rmdir.py C:\test\com.comp.hw.prod.proj.war\bin ['.svn', 'com'] d .svn dotd C:\test\com.comp.hw.prod.proj.war\bin\.svn Traceback (most recent call last): File "C:\python\rmdir.py", line 14, in <module> rmtree(os.path.join(curdir, d)) File "C:\Python31\lib\shutil.py", line 235, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "C:\Python31\lib\shutil.py", line …

Member Avatar
0
2
Member Avatar

I want to walk a directory and ignore all the files or directories which names begin in '.' (e.g. '.svn'). Then I will process all the files. My test program walknodot.py does not do the job yet. Please help. [CODE]#!c:/Python31/python.exe -u import os path = "C:\\test\\com.comp.hw.prod.proj.war\\bin" for dirpath, dirs, files in os.walk(path): print (dirpath) print (dirs) print (files) for filename in files: print ("filename " + filename) print (dirs) if "^.*" in dirs: continue if "^.*" in filename: continue print ("no . ") # process the files here [/CODE] C:\python>walknodot.py C:\test\com.comp.hw.prod.proj.war\bin ['.svn', 'com'] [] C:\test\com.comp.hw.prod.proj.war\bin\.svn ['prop-base', 'props', 'text-base', 'tmp'] ['entries', …

Member Avatar
0
7
Member Avatar

I want to call a C++ program from PHP with apache server on Fedora 12 linux. testprog is put in the same directory of the test php program. I see the output of exec('ls -lrt') but not exec("testprog"). Please help. The following are my php and cpp test programs. [CODE]<html> <head> <title>PHP Test</title> </head> <body> <?php echo exec('ls -lrt'); echo exec("testprog"); ?> </body> </html>[/CODE] testprog.cpp [CODE]#include <iostream> #include <algorithm> int main() { int array[] = { 23, 5, -10, 0, 0, 321, 1, 2, 99, 30 }; int elements = sizeof(array) / sizeof(array[0]); std::sort(array, array + elements); for (int i …

Member Avatar
0
5
Member Avatar

How to recursively walk directory & rename files & directories with Python 3.1 on windows? [CODE]#!c:/Python31/python.exe -u import os path = "test" for (path, dirs, files) in os.walk(path): print (path) print ("-----------------") if "monitoring" in path: dst = path.replace("monitoring", "managing", 10) print (dst) os.rename(path, dst) print ("path----") for file in files: if "hw" in file: print (file) dst = file.replace("hw", "hw2", 10) os.rename(file, dst) print (dst) print ("file----")[/CODE] My test program has this error: Traceback (most recent call last): File "C:\python\pathwalk.py", line 17, in <module> os.rename(file, dst) WindowsError: [Error 2] The system cannot find the file specified

Member Avatar
0
6
Member Avatar

The group button in my form is set to "unack". The Spring HwController receive the correct group "unack" when the "apply" button is clicked. However, the HwController receive the null group when the cursor is moved to the text box and press the <Enter> key. Only the data from the button is received incorrectly, the other form data are received correctly. Please help so that the HwController will receive the correct group when the <Enter> key is pressed. I use Spring 2.5.x to implement JSP. Eclipse console output: 12:56:52,187 INFO com.mycomp.hw.monitoring.war.HwController:57 - groupStr unack 12:56:52,187 INFO com.mycomp.hw.monitoring.war.HwController:60 - group unack …

Member Avatar
0
5
Member Avatar

My controller.java encounter an input string: "undefined". Please help. [CODE]public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { int rowsPerPage = 20; String rowsPerPageStr = request.getParameter("rowsPerPage"); logger.info("rowsPerPageStr " + rowsPerPageStr); if (rowsPerPageStr != null) { rowsPerPage = Integer.parseInt(rowsPerPageStr); }[/CODE] My jsp page use javascript as follows: [CODE]window.location = "hwdisplay?rowsPerPage=" + rowsPerPage;[/CODE] Eclipse Console output is: rowsPerPageStr undefined Servlet.service() for servlet hwmgr threw exception java.lang.NumberFormatException: For input string: "undefined"

Member Avatar
0
2
Member Avatar

I want to keep the value of the user input (e.g. text box value) displayed after page refresh by a javascript. The following test web page is used. The alerts appear before and after the page refresh as expected on all browsers (FF, Chrome, Opera & IE). The input value in a text box still appear after page refresh for IE but not FF, Chrome, Opera. Please help to make it work for FF, Chrome, Opera. [CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="css/style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Cookie</title> </head> <body> …

Member Avatar
0
5
Member Avatar

How to store variables in the jsp page scope with the spring 2.5.x framework? This has compile errors. [CODE]import javax.servlet.jsp.PageContext; @Override public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { PageContext pageContext; Object o = pageContext.getAttribute("com.mycompany.pageId");[/CODE] Description Resource Path Location Type The local variable pageContext may not have been initialized HwController.java /com.mycompany.monitoring.war/src/com/mycompany/monitoring/war line 59 Java Problem

Member Avatar
0
2
Member Avatar

Why the following code has the error: 'document.mainform.unknownHw' is null or not an object? function setUnknownHw(unknownHw) { document.mainform.unknownHw.checked = unknownHw; } <div class="special"> <form name="mainform" id="mainform" action="display.htm" method="post"> <br><br><input type="checkbox" name="unknownHw" onClick="setdbUnknownHw(this)">Unknown Hw <input type="submit" value="Apply" onClick="setdbRowsPerPage()"><br> </form> </div>

Member Avatar
0
3
Member Avatar

How to use "c:if" to test for the boolean true? These does not work: [CODE]<c:if test="${model.value == 'true' }"> <c:if test="${model.value == "true" }"> <c:if test="${model.value == true }">[/CODE]

Member Avatar
0
3
Member Avatar

After the apply button is clicked, the data entered by the user disappeared in the text form. How to keep the data appearing on the text form? The server use jsp and the Spring framework and the client use the Prototype javascript library.

Member Avatar
0
2
Member Avatar

I like to have a sleep or delay function in javascript. The Prototype library 1.6.1 has a delay function. It is working well in Firefox or Chrome but not IE 7 on windows XP. Please help (I cannot use newer version of windows). [CODE]function sleep() { } sleep.delay(0.1);[/CODE]

0
1
Member Avatar

To ensure my program keep the client preference after page refresh, do I do this: [CODE]var value = Cookie.get('key'); if (value == null) { // get the client preference // ... // save the client preference Cookie.set('key', 'uservalue'); } // use the client preference[/CODE]

0
1
Member Avatar

My table columns are sorted by the Tablekit library (millstream.com.au/upload/code/tablekit/). The user can click the columns to toggle the sort order either ascendingly or descendingly. I can save the current sort order (preference) in the server. After the page is refreshed, the web page is sorted by the original sort order. How to make the Tablekit library to sort with the current sort order after page refresh? My web page column is: <th class="sortfirstdesc" id="urgency" onClick="reverseOrder($sortdesc)">ID</th>

0
1
Member Avatar

After clicking the checkbox, I like to get the value of the checkbox submitted. Why the following page always get the value "20" for checkboxChoice and checkboxvalue no matter which checkbox I clicked? Please help. [CODE] <tr> <td> <div class='fg1'> <input type="checkbox" name="checkboxChoice" value="20" checked onclick="submit()"> Choice </div> <input type="hidden" name="checkboxvalue" value="20"> </td> </tr> <tr> <td> <div class='fg1'> <input type="checkbox" name="checkboxChoice" value="19" checked onclick="submit()"> Choice </div> <input type="hidden" name="checkboxvalue" value="19"> </td> </tr> <tr> <td> <div class='fg1'> <input type="checkbox" name="checkboxChoice" value="18" checked onclick="submit()"> Choice </div> <input type="hidden" name="checkboxvalue" value="18"> </td> </tr> <tr> <td> <div class='fg1'> <input type="checkbox" name=" <tr> <td> <div …

Member Avatar
0
3
Member Avatar

How to store some strings at the client side for firefox, chrome & IE? This code works on firefox & chrome but does not work on IE - no alert window appears. [CODE] var key = "localorder"; localStorage.setItem(key, 'asc'); alert('localorder ' + localStorage.getItem(key)); [/CODE] This code does not work on firefox, chrome nor IE - no alert window appears. [CODE] var key = "order"; sessionStorage.setItem(key, 'asc'); alert('order ' + sessionStorage.getItem(key));[/CODE] I use the Prototype JavaScript Framework on Windows Vista Home.

Member Avatar
0
2
Member Avatar

I use the Tablekit library and Prototype javascript framework on firefox, chrome & IE8. The columns in this table can be sorted by the Tablekit library. [CODE]<script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/tablekit.js"></script> <body> <div id="mainmenu"> ... </div> <div id="content"> <table class="sortable resizable"> <thead><tr> <th class="sortfirstdesc">ID</th> <th>Date</th> <th>Time</th> </tr></thead> </table> </div> </body> [/CODE] However, after adding the periodic refresh by AJAX (eventually I want to refresh only the web page when there is new data available) and <div>, then the columns in this table cannot be sorted by the Tablekit library. [CODE]<script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/tablekit.js"></script> <body onload="new Ajax.PeriodicalUpdater('topmenu', 'activity.htm', …

Member Avatar
0
2
Member Avatar

I want to set the value to <td><div class='urg5'>High</div></td> in JTSL. [CODE]I tried <c:set var="ack" value="<div class='urg5'>High</div>"/> <c:out value="${ack}"/> Page source of the JSP web page is &lt;div class=&#039;urg5&#039;&gt;High&lt;/div&gt;</td> i.e. special characters appear. instead of <div class='urg5'>High</div>[/CODE]

Member Avatar
0
2
Member Avatar

A "Confirm" window pop up for Firefox, IE but not Chrome for my web page with auto refresh every 10 seconds by javascript. Attached is the screen shot. How to stop this "Confirm" window from popping up?

0
1

The End.