js自动填写表单。

JavaScript012

js自动填写表单。,第1张

第一步: 在页面查看源代码,把Form中包含的需要填列的HTML控件找出来如:

<form name="mainfrm" action="" method="post">

<input type="text" name="username"/>

<input type="submit" value="submit"/>

</form>

第二步:编写代码 </strong>javascript:mainfrm.username.value="stangray"mainfrm.submit.focus()

第三步: 打开浏览器的“收藏夹”,在“链接”分类中添加一个URL收藏。

在URL项中:加入上面编写的代码,也可以指定快捷键,在名称中填写“自动填表”

第四步:测试在浏览器中打开你要填写表单的网址,然后点击“链接”栏(这个菜单栏在输入地址栏的右边<a href="http://www.codesky.net" class="hden">, 取消锁定工具栏后自动填表”链接。

自定义填充

除了鼠标拖拽操作之外,你也可以自定义填充数据。 它允许你在运行时设置,当你想给一片从数据源读出来的数据进行填充设置的时候,这将会非常有用。

有5种类型的填充数据:

Auto: 自动填充类型。

Direction: 填充方向。

Linear:线性填充类型。

Growth: 增长填充类型。

Date: 日期填充类型。

SpreadJS 提供了一些方法来执行填充操作。

// Fills the specified range automatically.

 

// When the value is a string, the value is copied to other cells.

// When the value is a number, the new value is generated by the TREND formula.

sheet.fillAuto(startRange, fillRange, {series: GC.Spread.Sheets.Fill.FillSeries.column, fillType: GC.Spread.Sheets.Fill.FillType.auto})

// Fills the specified range in the specified direction.

 

sheet.fillAuto(startRange, fillRange, {direction: GC.Spread.Sheets.Fill.FillDirection.left, fillType: GC.Spread.Sheets.Fill.FillType.direction}) 

// Fills the specified range linear trend when the source value type is number.

// The next value is generated by the step and stop values.

 

// The next value is computed by adding the step value to the current cell value. 

sheet.fillAuto(startRange, fillRange, {series: GC.Spread.Sheets.Fill.FillSeries.column, step: step, stop: stop, fillType: GC.Spread.Sheets.Fill.FillType.linear})

// Fills the specified range growth trend when the source value type is number.

 

// The next value is generated by the step and stop values.

 

// The next value is computed by multiplying the step value with the current cell.    sheet.fillAuto(startRange, fillRange, {series: GC.Spread.Sheets.Fill.FillSeries.column, step: step, stop: stop, fillType: GC.Spread.Sheets.Fill.FillType.growth} 

// Fills the specified range when the source value type is date.

 

// The next value is generated by adding the step value to the current value.

 

// The step value is affected by the fill date unit.

 

sheet.fillAuto(startRange, fillRange, {series: GC.Spread.Sheets.Fill.FillSeries.column, unit: GC.Spread.Sheets.Fill.FillDateUnit.month, step: step, stop: stop, fillType: GC.Spread.Sheets.Fill.FillType.date})

参考下面网址:网页链接

以jquery为例

<input class="ck" data="1">

<input class="ck" data="2">

<input class="ck" data="3">

var html

$( ".ck" ).click( function() {

    if( this.checked ) {

        html = '<input type="text" value="' + $( this ).attr( "data" ) + '">'

        $( "body" ).append( html )

    }

} )