時間跳轉和自增

時間跳轉:

<span id="time" style="background:red">5</span>秒鐘後自動跳轉,如果不跳轉,請點擊下面鏈接

<script language="JavaScript1.2" type="text/javascript">
<!--
//  Place this in the 'head' section of your page. 

function delayURL(url) {
 var delay = document.getElementById("time").innerHTML;
//alert(delay);
 if(delay > 0) {
  delay--;
  document.getElementById("time").innerHTML = delay;
 } else {
  window.top.location.href = url;
    }
    setTimeout("delayURL('" + url + "')", 1000); //delayURL(http://wwer)
}

 

自增id:

Connection conn = DB.getConn();

  boolean autoCommit = conn.getAutoCommit();
  conn.setAutoCommit(false);
  
  int rootId = -1;
  
  String sql = "insert into article values (null, ?, ?, ?, ?, now(), ?)";
  PreparedStatement pstmt = DB.prepareStmt(conn, sql, Statement.RETURN_GENERATED_KEYS);
  pstmt.setInt(1, 0);
  pstmt.setInt(2, rootId);
  pstmt.setString(3, title);
  pstmt.setString(4, cont);
  pstmt.setInt(5, 0);
  pstmt.executeUpdate();
  
  ResultSet rsKey = pstmt.getGeneratedKeys();
  rsKey.next();
  rootId = rsKey.getInt(1);
 
  Statement stmt = DB.createStmt(conn);
  stmt.executeUpdate("update article set rootid = " + rootId + " where id = " + rootId);

  conn.commit();
  conn.setAutoCommit(autoCommit);
  DB.close(pstmt);
  DB.close(stmt);
  DB.close(conn);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章