我没有在表格中给出确切的按钮数,因为当我在表格中添加一行时,当我点击编辑按钮时,它给了我2个按钮计数,其中表格中只有一个按钮,还有一个它也给出了当我想检查在表格中点击或不点击编辑按钮时,我会出现一些伪错误
$(document).ready(function() {
var count = 1;
$("#submit_Button").on('click', function() {
var fname_Field = $("#fname1").val();
var lname_Field = $("#lname1").val();
var address_Field = $("#address1").val();
if ($("#fname1").val() == null || $("#fname1").val() == "" && $("#lname1").val() == null || $("#lname1").val() == "" && $("#address1").val() == null || $("#address1").val() == "") {
alert("Please fill the form");
}
$(".above_Info").append('<tr><td>' + count + '</td><td>' + fname_Field + '</td><td>' + lname_Field + '</td><td>' + address_Field + '</td><td><input type="button" name="edit" id="edit_Button" value="Edit"/></td></tr>');
count++;
});
$(document).on('click', "input[type=button]", function() {
alert("I am in edit button");
var button_Count = $("input[type=button]").length;
alert(button_Count);
if ($("input[type=button]").is(":clicked")) {
alert("I am in button");
}
});
});
.form {
margin-left: 200px;
}
#address1 {
margin-left: 25px;
}
#fname1,
#lname1 {
margin-left: 9px;
}
#submit_Button {
margin-left: 95px;
}
.above_Info {
margin-left: 200px;
width: auto;
height: auto;
border: 1px solid #000;
}
<form name="myForm" class="form">
First Name : <input type="text" name="fname" id="fname1" /><br />
Last Name : <input type="text" name="lname" id="lname1" /><br />
Address : <input type="text" name="address" id="address1" /><br /><br /><br />
<input type="button" name="Submit" value="Submit" id="submit_Button" />
</form><br /><br /><br />
<table class="above_Info"></table>
答案 0 :(得分:1)
您尝试获取#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <cstdio>
#include <cstdlib>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "std_msgs/Int8.h"
#include <stdio.h>
using namespace cv;
using namespace std;
/// Global Variables
Mat img; Mat templ; Mat result;
char const* image_window = "Source Image";
char const* result_window = "Result window";
int match_method;
int max_Trackbar = 5;
// This is the position of line in the image
int line_position = 0;
void MatchingMethod( int, void* )
{
/// Source image to display
Mat img_display;
img.copyTo( img_display );
int image_width = img.cols;
/// Create the result matrix
int result_cols = img.cols - templ.cols + 1;
int result_rows = img.rows - templ.rows + 1;
result.create( result_rows, result_cols, CV_32FC1 );
/// Do the Matching and Normalize
matchTemplate( img, templ, result, match_method );
normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );
/// Localizing the best match with minMaxLoc
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
/// For SQDIFF and SQDIFF_NORMED, the best matches are lower values. For all the other methods, the higher the better
if ( match_method == CV_TM_SQDIFF || match_method == CV_TM_SQDIFF_NORMED )
{ matchLoc = minLoc; }
else
{ matchLoc = maxLoc; }
/// Show me what you got
rectangle( img_display, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(255), 2, 8, 0 );
rectangle( result, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(255), 2, 8, 0 );
imshow( image_window, img_display );
imshow( result_window, result );
return;
}
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
templ = imread("/home/davon/catkin_ws/src/test/src/temp1.png");
/// Create windows
namedWindow( image_window, CV_WINDOW_AUTOSIZE );
namedWindow( result_window, CV_WINDOW_AUTOSIZE );
/// Create Trackbar
char const* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
createTrackbar( trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod );
try {
img = cv_bridge::toCvShare(msg, "bgr8")->image;
MatchingMethod( 0, 0 );
waitKey(30);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
}
}//end of ImageCallback
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_listener");
ros::NodeHandle nh;
cv::startWindowThread();
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub = it.subscribe("ardrone/front/image_raw", 1, imageCallback);
ros::init(argc, argv, "line_position");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::Int8>("line_position", 30);
ros::Rate loop_rate(30);
while (ros::ok())
{
std_msgs::Int8 position;
position.data = line_position;
ROS_INFO("%d", position.data);
chatter_pub.publish(position);
ros::spinOnce();
loop_rate.sleep();
}
ros::spin();
}
而不是像这样使用last index
并递增它吗?
count