通过使用下面的代码,我试图获得div html值。我很难获得下拉选择值。我只是将此- select -agreedeny
改为选定值。如何仅获取所选值。对于此示例,请agree
或deny
代码
print <<HTML_TOP;
<!doctype html>
<html>
<head>
$tornadodocumentheader
<script type="text/javascript">
\$(document).ready(function(){
\$('#form').submit(function (e) {
e.preventDefault();
var \$form = \$('#form').data('Zebra_Form');
if (\$form.validate()) {
var contents = escape(\$('#myDiv').html());
//var contents = \$('#myDiv').html();
//var contents = escape(\$('#myDiv').HTML());
alert(contents);
contents = contents.replace(/%3D/g,"equaltoequaltoequalto");
\$.ajax({
cache: false,
url: 'pdfcontent.cgi?content='+contents+' ',
success: function(msg, ts, xh){
alert("success");
},
processData: false,
error: function(X, textStatus, error){
alert("Error saving... please try again now.")
}
});
}
});
});
</script>
</head>
<body>
<br>
<form name="form" id="form" action="#" method="post" class="Zebra_Form">
<div id="myDiv">
<h4>Project Name: $project</h4>
<h4>Job No: $workorderno</h4>
<h4>Processed By: $f_name</h4>
<h4>Processed On: $printdate</h4>
HTML_TOP
my $diff = XML::SemanticDiff->new(keepdata => 1,keeplinenums => 1);
$missingelementcounter=0;
$roguecounter =0;
$mismatchcounter =0;
foreach my $change ($diff->compare($f1, $f2)) {
if ($change->{message} ne "")
{
$processnos =1;
$message = $change->{message};
#print Dumper($change);
$new_value = $change->{new_value};
$old_value = $change->{old_value};
$context = $change->{context};
my ($value)=$message =~ m/Character differences in element ('[^>]*')/igs;
@arraymismatch[$mismatchcounter] = "$value;$new_value;$old_value;$context";
$mismatchcounter++;
}
}
$totalmismatch = scalar @arraymismatch;
print "Total Mismatch Elements: $totalmismatch\n";
print <<HTML_TOP;
<table align='center' border="1">
<thead>
<th>Element</th>
<th>Artwork XML</th>
<th>Tornado XML</th>
<th>Changes is accepted?</th>
<thead> <p></p>
<tbody>
HTML_TOP
for ($i=0;$i<(scalar @arraymismatch);$i++)
{
$temp = $arraymismatch[$i];
my @words = split /;/,, $temp;
$contextWords = @words[3];
my @wordsElement = split '[/.-]', $contextWords;
$missingElementposition = $wordsElement[3];
$find = "CopyElement[";
my $replace = "";
$find = quotemeta $find;
$missingElementposition =~ s/$find/$replace/g;
$find = "]";
my $replace = "";
$find = quotemeta $find;
$missingElementposition =~ s/$find/$replace/g;
XML::Twig->new( twig_handlers => # in the handler $_ is the department element
{ CopyElement => sub {
my $value = $_->att( 'CopyElementType');
@ElementNameArray[$counter] = $value;
$counter++;
}
}
)
->parsefile( $f2);
XML::Twig->new( twig_handlers => # in the handler $_ is the department element
{ CopyElement => sub {
my $value = $_->att( 'CopyElementType');
@ElementNameArray1[$counter] = $value;
$counter++;
}
}
)
->parsefile( $f1);
print <<HTML_TOP;
<tr class='row' align='left'><td>$ElementNameArray[$missingElementposition-1]</td><td>$words[1]</td><td>$words[2]</td><td><select name='acceptance$processnos' id='acceptance$processnos' class='control other'><option value=''>- select -</option><option value='agree'>agree</option><option value='deny'>deny</option></select></td></tr>
</div>
HTML_TOP