Get the form value in Boxy Plugin
Halo,
I use jQuery 1.3.2 with plugin Boxy 0.1.4.
http://onehackoranother.com/projects/jquery/boxy/index.html
In my site I use jQuery Boxy to open a "window" where I can edit rows.
I call per Boxy a ajax site:
-
function edit_row( id ){
Boxy.load("http://lcoalhost/procekt1/ajax/edit_row.php?d="+id, {title:'My Test', cache:false});
}
In the site edit_row.php code:
-
<?php
include_once('../CFgetdata.class.php');
function edit_rows()
{
global $_GET;
$cf = new CFgetdata();
$arr = $cf->get_daten_zu_editieren( $_GET['id'], $_GET['table'] );
$html ='';
$html.='<script type="text/javascript"> ';
$html.=' ';
$html.='function test1(){
var query_string = \'\';';
$html.='$("input[@type=\'text\']").each(';
$html.='function()
{
query_string += "&prog["+this.name+"]=" + this.value+"\n";
});';
$html.=' save_edit_row(\''.$_GET['id'].'\', \''.$_GET['table'].'\', this, query_string) ';
$html.=' } ';
$html.=' ';
$html.='</script>';
$html.='<form action="#" method="post" id="rownEdit">';
$html.='<table border="0" cellpadding="0" cellspacing="0" width="400">';
foreach ( $arr as $key => $value ) {
$html.='<tr>';
$html.='<td nowrap>';
$html.=$key.': ';
$html.='</td>';
$html.='<td>';
if ( $key == 'id' ) {
$html.=$value;
}
else {
$html.='<input type="text" name="'.$_GET['id'].'_'.$key.'" id="id'.$_GET['id'].'_'.$key.'" value="'.$value.'" size="25" maxlength="100" />';
}
$html.='</td>';
$html.='</tr>';
}
$html.='<tr>';
$html.='<td colspan="2"><hr></dt>';
$html.='</tr>';
$html.='<tr>';
$html.='<td>';
$html.='<input type="button" name="cancel" value="cancel" onclick="Boxy.get(this).hide();"/>';
$html.='</td>';
$html.='<td align="right">';
$html.='<input type="button" name="save" value="save" ';
$html.='onclick="test1(); ';
$html.='/>';
$html.='</td>';
$html.='</tr>';
$html.='</table>';
$html.='</form>';
echo $html;
}
edit_rows();
?>
If I click on Button "save" I get in the console from "Web Developer Toolbar" this error:
Fehler: uncaught exception: Syntax error, unrecognized expression: [@type='text']
But if I testet the code without ajax, here the code:
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function test2(){
var query_string = '';
var i=0;
$("input[@type='text']").each(
function()
{
query_string += "&prog["+this.name+"]=" + this.value+"\n";
});
alert("out: \n\n"+query_string);
}
</script>
</head>
<body>
<form action="#" id="myform" method="post">
<input type="text" name="nr1" value="value1"><br>
<input type="text" name="nr2" value="value2"><br>
<input type="text" name="nr3" value="value3"><br>
<input type="text" name="nr4" value="value4"><br>
<input type="text" name="nr5" value="value5"><br>
<input type="text" name="nr6" value="value6"><br>
<input type="text" name="nr7" value="value7"><br>
<br><br>
<input type="button" name="save" value="save" onclick="test2();">
</form>
</body>
</html>
The function "test2" working without problems.
Have anybody a idea way it not works with boxy or how can I to save the input fields in Boxy?
Regards
reg56