Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    213

    tabella dinamica+collegamenti

    ho una tabella costruita dinamicamente,cioè prende il num delle righe e delle colonne da input,e fin qui nessun problema,dovrei mettere xò anche un collegamento ipertestuale con cui si può aggiungere una colonna alla fine,come è possibile questo?il codice della tabella è questo:
    <html>
    <head>
    <title>My JSP 'tabdinamica.jsp' starting page</title>
    </head>
    <body>
    <center>
    <h1>Tabella dinamica</h1>
    <form method=post action=jsp/miejsp/prova/tabdinamica.jsp>
    Larghezza tabella (<16) = <input type=text name=WIDTH value=0 size=2>,
    Altezza tabella (<16) = <input type=text name=HEIGHT value=0 size=2>,
    <input type=submit value="Disegna!">
    </form>
    <hr>
    <% String w = request.getParameter("WIDTH");
    String h = request.getParameter("HEIGHT");
    if(w == null) w = "0";
    if(h == null) h = "0";
    int width = Integer.parseInt(w);
    int height = Integer.parseInt(h);
    if(width>15) width = 15;
    if(width<0) width = 0;
    if(height>15) height = 15;
    if(height<0) height = 0;
    <table border=0 cellpadding=0 cellspacing=0>
    <% for(int y=0; y<=height; y++){ %>
    <tr>
    <% for(int x=0; x<=width; x++){
    <td>
    (<%=x%>, <%=y%>)
    </td>
    <% } %>
    </tr>
    <% } %>
    </table>
    <a href=jsp/miejsp/prova/tabdinamica.jsp>
    Aggiungi una colonna</a>
    <hr>
    </center>
    </body>
    </html>

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013

    Re: tabella dinamica+collegamenti

    codice:
    <html>
      <head>
        <title>My JSP 'tabdinamica.jsp' starting page</title>
      </head>
      <body>
      <center>
      <h1>Tabella dinamica</h1>
      <form method="post" action="jsp/miejsp/prova/tabdinamica.jsp">
      Larghezza tabella (<16) = <input type="text" name="WIDTH" value="0" size="2">,
      Altezza tabella (<16) = <input type="text" name="HEIGHT" value="0" size="2">,
      <input type=submit value="Disegna!">
      </form>
      <hr>
      <% String w = request.getParameter("WIDTH");
      	 String h = request.getParameter("HEIGHT");
      	 if(w == null) w = "0";
      	 if(h == null) h = "0";
      	 int width = Integer.parseInt(w);
      	 int height = Integer.parseInt(h);
      	 if(width>15) width = 15;
      	 if(width<0) width = 0;
      	 if(height>15) height = 15;
      	 if(height<0) height = 0;
      <table border=0 cellpadding=0 cellspacing=0>
      <% for(int y=0; y<=height; y++){ %>
      		<tr>
      <%	for(int x=0; x<=width; x++){ 
       			<td>
      			(<%=x%>, <%=y%>)
      			</td>
      <%    } %>
      		</tr>
      <% } %>
      </table>
      Aggiungi una colonna
      <hr>  
      </center>
      </body>
    </html>
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    213
    grazie mille,io passavo solo width e non usavo &,grazie ancora,cmq se serve anche ad altri la riga corretta è:
    Aggiungi una colonna
    thank

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.