选择人机界面的简便化

戻る

新程序:直接按选择键选择

mscengine_nm.pl

sub mscengine_nm { my $self = shift; my(%t,$q,$template,$table,@rec); # Get CGI query object $q = $self->query(); $t{html} = $q->param("tmpl"); $t{html} = $t{html} . '.htm'; $template = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $q->param("id"); $t{name} = $q->param("name"); $t{series} = $q->param("series"); $t{title} = $q->param("title"); $t{table} = $q->param("table"); $t{item} = $q->param("item"); $t{sth} = $self->dbh->prepare("SELECT id,name,memo FROM $t{table}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { my $row_ref = (); # この初期化はとても重要! $$row_ref{id} = $rec[0]; $$row_ref{mname} = $rec[1]; $$row_ref{memo} = $rec[2]; $$row_ref{title} = $t{title}; $$row_ref{aid} = $t{id}; $$row_ref{name} = $t{name}; $$row_ref{series} = $t{series}; $$row_ref{item} = $t{item}; push(@loop, $row_ref); } $t{sth}->finish; $template->param(THIS_LOOP => \@loop); $template->param(aid => $t{id}); $template->param(name => $t{name}); $template->param(series => $t{series}); return $template->output; } 1;

mscengine_nm.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>主機の<TMPL_VAR NAME="title">選択</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>主機の<TMPL_VAR NAME="title">選択</h2></center> mode:modeengine_nm <form action="" method="post"> <input type="submit" value="主機データ追加へ戻る"><p> <input type="hidden" name="tmpl" value="mscengine_data"> <input type="hidden" name="id" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="rm" value="modeengine_data"> </form> <hr color="#003366"> aid==><TMPL_VAR NAME="aid"><br> name==><TMPL_VAR NAME="name"><br> series==><TMPL_VAR NAME="series"><br> <hr color="#003366"> <table> <tr bgcolor=white> <th>选择</th> <th>NO</th> <th>name</th> <th>memo</th> </tr> <TMPL_LOOP NAME="this_loop"> <tr bgcolor=cyan> <td> <form action="" method="post"> <input type="submit" value="选择"><p> <input type="hidden" name="tmpl" value="mscengine_nm1"> <input type="hidden" name="title" value="<TMPL_VAR NAME="title">"> <input type="hidden" name="aid" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="item" value="<TMPL_VAR NAME="item">"> <input type="hidden" name="rm" value="modeengine_nm1"> </form> </td> <td><TMPL_VAR NAME="id"></td> <td><TMPL_VAR NAME="mname"></td> <td><TMPL_VAR NAME="memo"></td> </tr> </TMPL_LOOP> </table> <hr color="#003366"> </BODY> </HTML>
老程序:先用radio点击选出,然后在回到最上面按选择

mscengine_nm.pl

sub mscengine_nm { my $self = shift; my(%t,$q,$template,$table,@rec); # Get CGI query object $q = $self->query(); $t{html} = $q->param("tmpl"); $t{html} = $t{html} . '.htm'; $template = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $q->param("id"); $t{name} = $q->param("name"); $t{series} = $q->param("series"); $t{title} = $q->param("title"); $t{table} = $q->param("table"); $t{item} = $q->param("item"); $t{sth} = $self->dbh->prepare("SELECT id,name FROM $t{table}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { my $row_ref = (); # この初期化はとても重要! $$row_ref{id} = $rec[0]; $$row_ref{Line} = $rec[1]; push(@loop, $row_ref); } $t{sth}->finish; $template->param(aid => $t{id}); $template->param(name => $t{name}); $template->param(series => $t{series}); $template->param(title => $t{title}); $template->param(item => $t{item}); $template->param(THIS_LOOP => \@loop); return $template->output; } 1;

mscengine_nm.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>主機の<TMPL_VAR NAME="title">選択</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>主機の<TMPL_VAR NAME="title">選択</h2></center> mode:modeengine_nm <form action="" method="post"> <input type="submit" value="主機データ追加へ戻る"><p> <input type="hidden" name="tmpl" value="mscengine_data"> <input type="hidden" name="id" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="rm" value="modeengine_data"> </form> <hr color="#003366"> aid==><TMPL_VAR NAME="aid"><br> name==><TMPL_VAR NAME="name"><br> series==><TMPL_VAR NAME="series"><br> <form action="" method="post"> <input type="submit" value="选择"><p> <TMPL_LOOP NAME="this_loop"> <INPUT TYPE="radio" NAME="id" VALUE=<TMPL_VAR NAME="id">><TMPL_VAR NAME="id">,<TMPL_VAR NAME="Line"><br> </TMPL_LOOP> <input type="hidden" name="tmpl" value="mscengine_nm1"> <input type="hidden" name="title" value="<TMPL_VAR NAME="title">"> <input type="hidden" name="aid" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="item" value="<TMPL_VAR NAME="item">"> <input type="hidden" name="rm" value="modeengine_nm1"> </form> <hr color="#003366"> </BODY> </HTML>

mscengine_nm1.pl

sub mscengine_nm1 { my $self = shift; my(%t,$q,$template,$table,@rec); # Get CGI query object $q = $self->query(); $t{html} = $q->param("tmpl"); $t{html} = $t{html} . '.htm'; $template = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{title} = $q->param("title"); $t{aid} = $q->param("aid"); $t{id} = $q->param("id"); $t{name} = $q->param("name"); $t{series} = $q->param("series"); $t{item} = $q->param("item"); $t{sql} = 'UPDATE main_type1 set ' . $t{item} . ' = "'; $t{sql} .= $t{id} . '" where id = ' . $t{aid}; $t{DO} = $self->dbh->do($t{sql}); $template->param(aid => $t{aid}); $template->param(id => $t{id}); $template->param(name => $t{name}); $template->param(series => $t{series}); $template->param(sql => $t{sql}); $template->param(DO => $t{DO}); $template->param(title => $t{title}); return $template->output; } 1;

mscengine_nm1.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>主機の<TMPL_VAR NAME="title">選択確定</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>主機の<TMPL_VAR NAME="title">選択確定</h2></center> mode:modeengine_nm1 <form action="" method="post"> <input type="submit" value="主機データ追加へ戻る"><p> <input type="hidden" name="tmpl" value="mscengine_data"> <input type="hidden" name="id" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="name" value="<TMPL_VAR NAME="name">"> <input type="hidden" name="series" value="<TMPL_VAR NAME="series">"> <input type="hidden" name="rm" value="modeengine_data"> </form> <hr color="#003366"> aid==><TMPL_VAR NAME="aid"><br> id==><TMPL_VAR NAME="id"><br> name==><TMPL_VAR NAME="name"><br> series==><TMPL_VAR NAME="series"><br> sql==><TMPL_VAR NAME="sql"><br> DO==><TMPL_VAR NAME="DO"><br> <hr color="#003366"> </BODY> </HTML>
戻る