razultull
11-01-2010, 04:51 PM
Hey so I'm trying to create a dynamic table in javascript such that you have an HTML file with a form, for a webpage im making.
<form action="table" method="get">
<label>
Start Number:
<input type="text" name="start" size="10"/>
</label>
<label>
End Number:
<input type="text" name="end" size="10"/>
</label>
<label>
Limit:
<input type="text" name="limit" size="10"/>
</label>
<input type="submit" name="mult" value="Create this table"/>
</form>
This html is separate from the servlet i am trying to write that will exist in a jsp/java file.
Basically the output should be something like
<table>
<tr><td>4*0=0</td><td>4*1=4</td><td>4*2=8</td></tr>
<tr><td>5*0=0</td><td>5*1=5</td><td>5*2=10</td></tr>
<tr><td>6*0=0</td><td>6*1=6</td><td>6*2=12</td></tr>
</table>
but embedded....
There are THREE inputs by the user, start, end , limit.
I think i have got a general idea of how to do it, but am a bit fuzzy on how to implement the logic with the actual printing of the html in the document.
i know i have to use for loops but am unsure how.
This is the method i would like to adhere to, i dont want to use inline javascript because there is going to be some flash in there as well.
this is the javascript i have come up with so far
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
Public class Table extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
public class Counter extends HttpServlet {
private int v;
private List<String> starts;
private List<String> ends;
private List<String> mults;
public void init() {
v = 0;
starts = new ArrayList<String>();
ends = new ArrayList<String>();
mults = new ArrayList<String>();
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String start = req.getParameter("start");
String end = req.getParameter("end");
String mult = req.getParameter("mult");
for(int i = 1; i <= start ; i++)
{
}
}
PrintWriter o = res.getWriter();
String r =
"<html><head><title>Multiplication Result</title></head>" +
;
}
Thanks in advance to anyone who can help.
<form action="table" method="get">
<label>
Start Number:
<input type="text" name="start" size="10"/>
</label>
<label>
End Number:
<input type="text" name="end" size="10"/>
</label>
<label>
Limit:
<input type="text" name="limit" size="10"/>
</label>
<input type="submit" name="mult" value="Create this table"/>
</form>
This html is separate from the servlet i am trying to write that will exist in a jsp/java file.
Basically the output should be something like
<table>
<tr><td>4*0=0</td><td>4*1=4</td><td>4*2=8</td></tr>
<tr><td>5*0=0</td><td>5*1=5</td><td>5*2=10</td></tr>
<tr><td>6*0=0</td><td>6*1=6</td><td>6*2=12</td></tr>
</table>
but embedded....
There are THREE inputs by the user, start, end , limit.
I think i have got a general idea of how to do it, but am a bit fuzzy on how to implement the logic with the actual printing of the html in the document.
i know i have to use for loops but am unsure how.
This is the method i would like to adhere to, i dont want to use inline javascript because there is going to be some flash in there as well.
this is the javascript i have come up with so far
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
Public class Table extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
public class Counter extends HttpServlet {
private int v;
private List<String> starts;
private List<String> ends;
private List<String> mults;
public void init() {
v = 0;
starts = new ArrayList<String>();
ends = new ArrayList<String>();
mults = new ArrayList<String>();
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String start = req.getParameter("start");
String end = req.getParameter("end");
String mult = req.getParameter("mult");
for(int i = 1; i <= start ; i++)
{
}
}
PrintWriter o = res.getWriter();
String r =
"<html><head><title>Multiplication Result</title></head>" +
;
}
Thanks in advance to anyone who can help.