根据首次询问的输入设置输入类型范围的最小值

时间:2016-02-01 11:33:13

标签: javascript jquery html

我有两个输入类型范围,第一个输入的最小值设置为0。 我想根据第一个输入设置第二个输入类型范围的最小值。

select row_number() , .....
from....
order by ....

与第一个输入相似,我选择2作为值。我希望下一个输入的最小值为3。

感谢

3 个答案:

答案 0 :(得分:1)

<强> HTML

<input type="number" class="first" min="0">
<input type="number" class="second" min="0">

的jQuery

$(document).ready(function(){
  $('.first').keyup(function(){
    var a = $(this).val();
    $('.second').attr('min',a);
  });
});

答案 1 :(得分:0)

在第一个输入的操作中,获取输入的数值并更改第二个输入的min值。这是纯JavaScript中的一个例子:

function onFirstInput() {
    var input1 = document.getElementById("firstInput").value;
    var newMin = Number(input1)
    //Insert any other statements that process the new min here
    document.getElementById("secondInput").min = newMin;
}

答案 2 :(得分:0)

在第一个范围输入上侦听'change'事件并运行一个函数,将第二个输入的最小值设置为第一个范围输入的当前值加1.获取元素的值将返回一个字符串,因此需要+ (void) gernalDeleteRequest:(NSDictionary *)headerParams urlQuery: (NSString*)action parameters:(NSDictionary*)params onComplete:(void (^)(id json, id code))successBlock onError:(void (^)(id error, id code))errorBlock { NSString *jsonString = @""; NSString *authorizationValue = [self setAuthorizationValue:action]; NSString *language = @"en_US"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:language forHTTPHeaderField:@"Accept-Language"]; [request setValue:authorizationValue forHTTPHeaderField:@"authorization"]; //convert parameters in to json data if ([params isKindOfClass:[NSDictionary class]]) { NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:NSJSONWritingPrettyPrinted error:&error]; jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } [request setURL:[NSURL URLWithString:action]]; [request setTimeoutInterval:500.0]; [request setHTTPMethod:@"DELETE"]; NSMutableData *postBody = [NSMutableData data]; [postBody appendData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:postBody]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request]; operation.responseSerializer = [AFJSONResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSInteger statusCode = [operation.response statusCode]; NSNumber *statusObject = [NSNumber numberWithInteger:statusCode]; successBlock(responseObject, statusObject); NSLog(@"authentication success"); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSInteger statusCode = [operation.response statusCode]; NSNumber *statusObject = [NSNumber numberWithInteger:statusCode]; id responseObject = operation.responseData; id json = nil; NSString *errorMessage = nil; if (responseObject) { json = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:&error]; errorMessage = [(NSDictionary*)json objectForKey:@"Message"]; }else{ json = [error.userInfo objectForKey:NSLocalizedDescriptionKey]; errorMessage = json; } errorBlock(errorMessage, statusObject); }]; [[NSOperationQueue mainQueue] addOperation:operation]; 才能转换为数字,以便可以添加1。

parseInt()