我想在每次用户检查单选按钮时更改隐藏输入字段的值.
这就是我的HTML的样子.
<input type="hidden" id="ZAAL_NAME" value="" name="ZAAL_NAME" />
<input type="radio" name="zaal_ID" value="ROOM1" onclick="change">
<input type="radio" name="zaal_ID" value="ROOM2" onclick="change">
<input type="radio" name="zaal_ID" value="ROOM3" onclick="change">
Run Code Online (Sandbox Code Playgroud)
现在我希望每次检查单选按钮时,该单选按钮的值也变为隐藏输入字段的值.有谁知道怎么做?这是我到目前为止所拥有的.
$('input[name="radbut"]').click(function() {
console.log(this.value);
$('ZAAL_NAME').val(this.value);
});
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
亲切的问候,
Steaphann
我在gridview中生成了一堆imageview.但是现在我希望每个imageview可以做到另一个屏幕.有人知道我怎么做吗?这是我如何生成我的imageview并将其放入网格的代码.
UIImageView * myView = [[UIImageView alloc] initWithImage:myImage];
CGRect rect = myView.frame;
rect.origin.x = xCurrent;
rect.origin.y = yCurrent;
myView.frame = rect;
myView.tag = cellCounter;
[gridContainerView addSubview:myView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
myView.userInteractionEnabled = YES;
[myView addGestureRecognizer:tap];
Run Code Online (Sandbox Code Playgroud)
请帮忙
亲切的问候
我想把我的JSON变成一个NSDictionary.我正在做以下事情:
NSData *innerData = [json objectForKey:@"data"];
NSLog(@"Inner Description %@", innerData);
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:innerData
options:kNilOptions
error:&error];
NSLog(@"dict: %@",json);
Run Code Online (Sandbox Code Playgroud)
它一直在崩溃创建字典与此错误.
-[__NSCFDictionary bytes]: unrecognized selector sent to instance 0x1e8d6100
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
我正在使用jquery mobile构建移动webapp.现在我想做两件事.有一点是只能检查一个复选框.另一件事是,当有另一个复选框时,我不想修改我的JavaScript.
我的HTML
<input type="checkbox" name="checkbox-zaal1" id="checkbox-1" onClick="CountChecks('checkbox-1')"/>
<label for="checkbox-1">Zaal 1</label>
<input type="checkbox" name="checkbox-zaal2" id="checkbox-2" onClick="CountChecks('checkbox-2')"/>
<label for="checkbox-2">Zaal 2</label>
<input type="checkbox" name="checkbox-zaal3" id="checkbox-3" onClick="CountChecks('checkbox-3')"/>
<label for="checkbox-3">Zaal 3</label>
Run Code Online (Sandbox Code Playgroud)
还有我的javascript
function CountChecks(which) {
var maxchecked = 1;
var count = 0;
for (i=0;i<=3;i++){
if(eval('document.getElementById("checkbox-"+ i).checked == true')) { count++; }
}
if(count > maxchecked) {
eval('document.getElementById("' + which + '").checked = false');
alert('Sorry je kan enkel maar 1 meeting room reserveren');
}
}
Run Code Online (Sandbox Code Playgroud)
所以你可以在我的javascript中看到.我想在页面上的金额关闭复选框中更改for循环中的3.我的第一个eval函数也有问题.但我无法弄明白.
你可以帮帮我吗 ?
谢谢
我试图将我的tableview分成每个月的部分.我开始使用apple 的DateSectionTitles示例.首先,我在核心数据库中添加了一个属性"sectionIdentifier".然后在我的managedobject子类中添加了这个方法.
- (NSString *)sectionIdentifier {
// Create and cache the section identifier on demand.
[self willAccessValueForKey:@"sectionIdentifier"];
NSString *tmp = [self primitiveSectionIdentifier];
[self didAccessValueForKey:@"sectionIdentifier"];
if (!tmp) {
/*
Sections are organized by month and year. Create the section identifier as a string representing the number (year * 1000) + month; this way they will be correctly ordered chronologically regardless of the actual name of the month.
*/
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | …Run Code Online (Sandbox Code Playgroud) 我正在使用Yahoo api创建一个小天气应用程序.这个api给了我一个XML文件.我现在的问题是如何解析这个文件?这是我到目前为止的代码.
AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
NSLog(@"success");
XMLParser.delegate = self;
[XMLParser parse];
NSLog(@"xmlParser is %@",XMLParser);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser) {
NSLog(@"failure with error %@",error);
}];
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到XML文件.
希望有人能帮助我
我有一个NSArray,我想用谓词过滤.这就是我所拥有的.
NSLog(@"text is %@",txtSearch.text);
NSPredicate *bPredicate =
[NSPredicate predicateWithFormat:@"SELF beginswith[c] '%@'",txtSearch.text];
arrSearchedPlayers =
[arrPlayers filteredArrayUsingPredicate:bPredicate];
NSLog(@"array after searched is %@",arrSearchedPlayers);
Run Code Online (Sandbox Code Playgroud)
当我输入文本时,我的数组保持为空.但是当我尝试这个谓词时,
NSPredicate *bPredicate =
[NSPredicate predicateWithFormat:@"SELF beginswith[c] 's'"];
Run Code Online (Sandbox Code Playgroud)
我得到了正确的结果.任何人都知道问题是什么?
亲切的问候
我试图将一个int从一个VC传递到另一个VC.我是这样做的.
在我的VC1中,showDetail当我调用prepareForSegue方法时,我正在做一个segue .看起来像这样.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = (NSIndexPath *)sender;
News *news = [arrNews objectAtIndex:indexPath.row];
NSLog(@"news id is %@",news.new_id);
if ([segue.identifier isEqualToString:@"showDetail"]) {
[segue.destinationViewController setNewsId:(int)news.new_id];
}
}
Run Code Online (Sandbox Code Playgroud)
在Log中我得到了正确的数字.现在在我的VC2中,我已经声明了这样的int.
@property (nonatomic) int newsId;
Run Code Online (Sandbox Code Playgroud)
我的setMethod看起来像这样.
-(void)setNewsId:(int)newsId{
NSLog(@"news id is %d",newsId);
self.newsId = newsId;
}
Run Code Online (Sandbox Code Playgroud)
当我执行时,我进入了一个包含所有大数字的循环.有人可以帮我解决这个问题吗?
我在字符串中有以下数字数组.
08,
03,
11,
06,
01,
09,
12,
07,
02,
10
Run Code Online (Sandbox Code Playgroud)
我希望它是:
06,
07,
08,
09,
10,
11,
12,
01,
02,
03
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我在考虑使用这样的自定义比较器:
NSComparisonResult compare(NSString *numberOne, NSString *numberTwo, void *context)
Run Code Online (Sandbox Code Playgroud)
但以前从未使用它.
任何帮助?
亲切的问候
编辑
好的,所以此刻我做到了这一点.
NSArray *unsortedKeys = [self.sectionedKalender allKeys];
NSMutableArray *sortedKeys = [[NSMutableArray alloc]initWithArray:[unsortedKeys sortedArrayUsingSelector:@selector(localizedCompare:)]];
Run Code Online (Sandbox Code Playgroud)
这将从01 - > 12对数组进行排序.这些数字代表我在tableview中的月份.目前在Januari开始,12月停止.我现在想要的是从六月开始到三月结束.
希望这可以解决一些问题.
我正在尝试将我的JSON解析为NSDictionary.这是我用于解析的方法.
+ (NSDictionary *)executeGenkFetch:(NSString *)query
{
query = [NSString stringWithFormat:@"%@", query];
query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"[%@ %@] sent %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), query);
NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error] : nil;
if (error) NSLog(@"[%@ %@] JSON error: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), error.localizedDescription);
NSLog(@"[%@ %@] received %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), results);
return results;
}
Run Code Online (Sandbox Code Playgroud)
以下是我如何使用此功能.
+(NSArray *)getCommentsWithParam:(NSString *)Param
{
NSString *request = [NSString stringWithFormat:@"https://graph.facebook.com/comments/?ids=%@",Param];
NSLog(@"request …Run Code Online (Sandbox Code Playgroud) objective-c ×8
ios ×7
iphone ×4
html ×2
javascript ×2
jquery ×2
json ×2
nsarray ×2
afnetworking ×1
core-data ×1
gridview ×1
ipad ×1
nsdictionary ×1
nspredicate ×1
nsstring ×1
segue ×1
storyboard ×1
uiimageview ×1
xml ×1