JavaScript如何将数据添加到变量

时间:2015-12-18 23:40:51

标签: javascript

我有

Addbutton

在用户点击 <table id="tbForm1" border="1"> <tbody> </tbody> </table>

时添加到表格
table

但是我想存储它(var JavaScript)并在用户点击添加时分配给其他一个变量和所有行。我怎么样?

修改 我不知道PHP的语法,但如果它是 $ba .= 'a'; if(click=='add'){ $ba .='b'; } echo $ba; //outup ab ,我的意思是:

@implementation MMXRotateChannel

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.cstrip = [[MMXChannelStripView alloc] init];
        [self addSubview:self.cstrip];

        return self;
    }
    return nil;
}

// this works for any size of this view.  the slider will always be as tall as this view is wide
- (void)layoutSubviews {
    [super layoutSubviews];

    // size it to be as wide as this view's height, center it in this view
    self.cstrip.bounds = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.width);

    self.cstrip.center = [self convertPoint:self.center fromView:self.superview];

    // rotate it
    self.cstrip.transform = CGAffineTransformMakeRotation(M_PI * .5);

}

@end

1 个答案:

答案 0 :(得分:0)

正如Vohuman所提到的,使用该函数创建带有Id的动态行,并使用下面的方法将该行添加到另一个表中。

var x =document.getElementById("tbForm1").getElementsByTagName('tbody');
x.innerHTML = generateRow(id);

另请参阅此处以添加后续行

How to insert row in HTML table body in javascript?