java代码实现全选 js怎么实现全选

java 关键字全部选中怎么实现?

你应该是想全局替换某一个关键字。

阿里地区网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联公司2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

选定文本域之后,按下Ctrl + F,选择里面的相关选项即可,我认为你可以看懂。

java web项目 一个jsp中增加一个全选功能(前后段) 本人没做过 想参考各位提供的例子学习学习

//多选框

table id='tab' width="300"

tr

tdlabelinput name="mk" type="checkbox" value="1" /XX/label/td

tdlabelinput name="mk" type="checkbox" value="1" /XX/label/td

/tr

/table

//全选全部选按钮

input type="button" value="全选"  style="width:50px"  id="selectAll"

input type="button" value="全不选" style="width:50px" id="unSelect"

//事件

$("#selectAll").click(function () {

$("#tab :checkbox,#all").prop("checked", true);  

});

$("#unSelect").click(function () {  

$("#tab :checkbox,#all").prop("checked", false);  

});

这是我之前写的  你照着改改吧

java 关于复选框全选反选

function selall(obj){

for (var i=0;iobj.elements.length;i++){

var e = obj.elements[i];

if (e.name == 'idd'){

var v=e.checked;

break;

}

}

for (var i=0;iobj.elements.length;i++){

var e = obj.elements[i];

if (e.name == 'id')

e.checked = v;

}

}

全选/反选td style="width:50px;" class="edit"input type="checkBox" name="idd" value="1" onClick="selall(f1)"/td

删除 td style="width:50px;" class="edit"input type="checkBox" name="id" value="${aa.NId}"/td

java servlet下面代码怎么实现全选啊

用jquery 脚本实现吧兄弟

为选择按钮注册点击事件{

$(".每一个车位div").attr( 属性名: 属性值);

}

让每一个车位都有相同的class

attr 后面就为他设置style就好了

用java编写记事本程序,可以实现新建、打开、保存、退出、复制、粘贴、剪切、全选。

import javax.swing.*;

import javax.swing.filechooser.FileFilter;

import java.awt.event.*;

import java.awt.*;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Enumeration;

import java.util.Hashtable;

public class MyText extends JFrame implements ActionListener{

private JLabel lb1;

private JMenuBar mb;

private JMenu 文件, 编辑, 格式, 帮助;

private JMenuItem 新建, 打开, 保存, 退出, 复制, 粘贴, 剪切, 全选, 字体, 关于;

private JTextArea editorArea;

private boolean isDirty = false;

private String strFileName = "未命名";

private static final String EDITOR_NAME = "MyText";

public MyText() {

super();

mb = new JMenuBar();

文件 = new JMenu("文件");

编辑 = new JMenu("编辑");

格式 = new JMenu("格式");

帮助 = new JMenu("帮助");

新建 = new JMenuItem("新建");

新建.addActionListener(this);

打开 = new JMenuItem("打开");

打开.addActionListener(this);

保存 = new JMenuItem("保存");

保存.addActionListener(this);

退出 = new JMenuItem("退出");

退出.addActionListener(this);

复制 = new JMenuItem("复制");

复制.addActionListener(this);

粘贴 = new JMenuItem("粘贴");

粘贴.addActionListener(this);

剪切 = new JMenuItem("剪切");

剪切.addActionListener(this);

全选 = new JMenuItem("全选");

全选.addActionListener(this);

字体 = new JMenuItem("字体");

字体.addActionListener(this);

关于 = new JMenuItem("关于");

关于.addActionListener(this);

mb.add(文件);

mb.add(编辑);

mb.add(格式);

mb.add(帮助);

文件.add(新建);

文件.add(打开);

文件.add(保存);

文件.add(退出);

编辑.add(复制);

编辑.add(粘贴);

编辑.add(剪切);

编辑.add(全选);

格式.add(字体);

帮助.add(关于);

setJMenuBar(mb);

Container container = getContentPane();

editorArea = new JTextArea();

editorArea.setLineWrap(true);

editorArea.addKeyListener(new KeyAdapter() {

public void keyPressed(KeyEvent e) {

if(!isDirty()){

setDirty(true);

}

}

});

JScrollPane scrollPane = new JScrollPane(editorArea);

container.add(scrollPane);

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e){

dispose();

}

});

setTitle(formatEditorTitle());

setSize(600, 400);

setVisible(true);

}

private boolean isDirty() {

return isDirty;

}

private void setDirty(boolean isDirty) {

this.isDirty = isDirty;

setTitle(formatEditorTitle());

}

public static void main(String args[]) {

@SuppressWarnings("unused")

MyText app = new MyText();

}

public void actionPerformed(ActionEvent e) {

JMenuItem item = (JMenuItem)e.getSource();

if(item.equals(新建)){

if(isDirty()){

int ret = JOptionPane.showConfirmDialog(getContentPane(), "文件内容已经变动,是否保存?", "MyText", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);

if(ret == JOptionPane.OK_OPTION){

saveFile();

}else if(ret == JOptionPane.CANCEL_OPTION || ret == JOptionPane.CLOSED_OPTION){

return;

}

}

clearEditorArea();

setDirty(false);

}else if(item.equals(打开)){

if(isDirty()){

int ret = JOptionPane.showConfirmDialog(getContentPane(), "文件内容已经变动,是否保存?", "MyText", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);

if(ret == JOptionPane.OK_OPTION){

saveFile();

}else if(ret == JOptionPane.CANCEL_OPTION || ret == JOptionPane.CLOSED_OPTION){

return;

}

}

openFile();

}else if(item.equals(保存)){

saveFile();

}else if(item.equals(退出)){

dispose();

}else if(item.equals(复制)){

editorArea.copy();

}else if(item.equals(剪切)){

editorArea.cut();

}else if(item.equals(粘贴)){

editorArea.paste();

}else if(item.equals(全选)){

editorArea.selectAll();

}else if(item.equals(字体)){

FontDialog font = new FontDialog(this, editorArea.getFont());

editorArea.setFont(font.getSelectedFont());

}else if(item.equals(关于)){

AboutDialog about = new AboutDialog(this);

about.setVisible(true);

}

}

private String getFileName() {

return strFileName;

}

private void setFileName(String strFileName) {

this.strFileName = strFileName;

}

public String formatEditorTitle(){

StringBuffer strFileNm = new StringBuffer(getFileName());

strFileNm.append(isDirty()?"*":"");

strFileNm.append(" - ");

strFileNm.append(EDITOR_NAME);

return strFileNm.toString();

}

private void clearEditorArea(){

editorArea.selectAll();

editorArea.replaceSelection("");

}

private void openFile(){

JFileChooser openDialog = new JFileChooser();

openDialog.setFileFilter(new TxtFileFilter());

if(openDialog.showOpenDialog(getContentPane()) == JFileChooser.APPROVE_OPTION){

File file = openDialog.getSelectedFile();

BufferedReader br = null;

try {

br = new BufferedReader(new FileReader(file));

String buff = br.readLine();

clearEditorArea();

while(buff != null){

editorArea.append(buff);

editorArea.append("\n");

buff = br.readLine();

}

} catch (FileNotFoundException e1) {

e1.printStackTrace();

} catch (IOException ioe) {

ioe.printStackTrace();

} finally{

try{

if(br != null)

br.close();

} catch (IOException ioe){

ioe.printStackTrace();

}

}

}

}

private void saveFile(){

JFileChooser saveDialog = new JFileChooser();

saveDialog.setFileFilter(new TxtFileFilter());

if(saveDialog.showSaveDialog(getContentPane()) == JFileChooser.APPROVE_OPTION){

File file = saveDialog.getSelectedFile();

BufferedWriter bw = null;

try {

bw = new BufferedWriter(new FileWriter(file));

String buff = editorArea.getText();

bw.write(buff);

} catch (IOException ioe) {

ioe.printStackTrace();

} finally{

try{

if(bw != null)

bw.close();

} catch (IOException ioe){

ioe.printStackTrace();

}

}

}

}

class TxtFileFilter extends FileFilter{

@Override

public boolean accept(File f) {

return f.isDirectory() || f.getName().toLowerCase().endsWith(".txt");

}

@Override

public String getDescription() {

return "*.txt(文本文件)";

}

}

class FontDialog extends JDialog{

private JComboBox cb_FontSize;

private JComboBox cb_FontStyle;

private JComboBox cb_FontNm;

private Font font;

HashtableInteger, String style = new HashtableInteger, String();

public FontDialog(){

this(null, null);

}

public FontDialog(Frame owner, Font font){

super(owner);

this.font = font == null?getFont():font;

setTitle("字体选择框");

setModal(true);

setResizable(false);

setSize(326, 164);

getContentPane().setLayout(null);

final JLabel lb_FontNm = new JLabel();

lb_FontNm.setText("字体名称");

lb_FontNm.setBounds(10, 10, 66, 16);

getContentPane().add(lb_FontNm);

cb_FontNm = new JComboBox();

cb_FontNm.setBounds(10, 28, 133, 25);

getContentPane().add(cb_FontNm);

cb_FontStyle = new JComboBox();

cb_FontStyle.setBounds(169, 28, 66, 25);

getContentPane().add(cb_FontStyle);

cb_FontSize = new JComboBox();

cb_FontSize.setBounds(258, 28, 53, 25);

getContentPane().add(cb_FontSize);

final JButton btn_OK = new JButton();

btn_OK.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

int styleCode = 0;

for(EnumerationInteger i = style.keys();i.hasMoreElements();){

styleCode = i.nextElement();

if(style.get(styleCode).equals(cb_FontStyle.getSelectedItem()))

break;

}

Font font = new Font(cb_FontNm.getSelectedItem().toString(), styleCode, ((Integer)cb_FontSize.getSelectedItem()).intValue());

setSelectedFont(font);

dispose();

}

});

btn_OK.setText("确定");

btn_OK.setBounds(58, 83, 76, 26);

getContentPane().add(btn_OK);

final JButton btn_Cancel = new JButton();

btn_Cancel.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

dispose();

}

});

btn_Cancel.setText("取消");

btn_Cancel.setBounds(169, 83, 76, 26);

getContentPane().add(btn_Cancel);

final JLabel lb_FontStyle = new JLabel();

lb_FontStyle.setText("字体样式");

lb_FontStyle.setBounds(169, 10, 66, 16);

getContentPane().add(lb_FontStyle);

final JLabel lb_FontSize = new JLabel();

lb_FontSize.setText("字体大小");

lb_FontSize.setBounds(258, 10, 66, 16);

getContentPane().add(lb_FontSize);

init();

setVisible(true);

}

private void init(){

GraphicsEnvironment gg=GraphicsEnvironment.getLocalGraphicsEnvironment();

String ss[]=gg.getAvailableFontFamilyNames();

for(String s : ss)

cb_FontNm.addItem(s);

if(font != null)

cb_FontNm.setSelectedItem(font.getFamily());

style.put(Font.PLAIN, "标准");

style.put(Font.BOLD, "粗体");

style.put(Font.ITALIC, "斜体");

style.put(Font.BOLD+Font.ITALIC, "粗体斜体");

cb_FontStyle.addItem(style.get(Font.PLAIN));

cb_FontStyle.addItem(style.get(Font.BOLD));

cb_FontStyle.addItem(style.get(Font.ITALIC));

cb_FontStyle.addItem(style.get(Font.BOLD+Font.ITALIC));

if(font != null)

cb_FontStyle.setSelectedItem(style.get(font.getStyle()));

for(int i=8;i23;i++)

cb_FontSize.addItem(i);

if(font != null)

cb_FontSize.setSelectedItem(font.getSize());

}

public Font getSelectedFont() {

return font;

}

public void setSelectedFont(Font font) {

this.font = font;

}

}

class AboutDialog extends JDialog{

public AboutDialog(JFrame owner){

super(owner);

setTitle("关于");

setSize(new Dimension(322, 163));

getContentPane().setLayout(null);

final JLabel version = new JLabel();

version.setText("MyText 1.0");

version.setBounds(74, 37, 66, 16);

getContentPane().add(version);

final JLabel copyright = new JLabel();

copyright.setText("Copyright (C) 2010");

copyright.setBounds(74, 59, 188, 16);

getContentPane().add(copyright);

final JSeparator separator = new JSeparator();

separator.setBounds(70, 90, 210, 2);

getContentPane().add(separator);

final JButton okButton = new JButton();

okButton.setBounds(235, 95, 50, 26);

getContentPane().add(okButton);

okButton.setText("Ok");

okButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

dispose();

}

});

}

}

}


当前文章:java代码实现全选 js怎么实现全选
路径分享:http://scyanting.com/article/higgep.html