2017-05-24 17 views
6

我在網站上有一個表單,我需要手動提交數百條記錄。該表單在POST方法中。如何在POST方法中填充表單

我嘗試過簡單:http://.../form?incomingLead__email=MYNAME。但這不起作用。

如何操作表單提交操作以包含值?

enter image description here

與單場如下嘗試:這是一個從HTML的First Name屬性:

<input id="incomingLead__firstName" name="incomingLead__firstName" 
class="text" style="" type="text" onkeypress="var _this=this;return 
onEnterPressed(event, function() 
{document.controller.setValue('/ctx/incomingLead/@firstName', 
_this.value, 'incomingLead__firstName');return true;});" 
onblur="document.controller.setValue('/ctx/incomingLead/@firstName', 
this.value, 'incomingLead__firstName')"> 

form屬性是:

<form method="post" name="page" class="main-navigation" id="page-form"> 

提交按鈕:

<button type="button" id="link-link330" onclick="return linklink330();">Submit</button> 

驗證JS功能:

function toValidate() { 
 
    var temp = document.getElementById('temp') 
 
    if (!temp) return document.controller.submit('submit'); 
 

 
    document.controller.setValue("/ctx/vars/iCountProducts", temp.options.length); 
 

 

 
    for (var i = 0; i < temp.options.length; i++) 
 
    document.controller.setValue("/ctx/vars/products/product" + i, temp.options[i].value); 
 

 
    return document.controller.submit('submit'); 
 
}

我認爲具有Excel文件,並連接我需要的鏈接,至少我可以減少時間表單填充數據,成2次點擊:一個在excel中打開webform,並提交。

給定的數據有可能嗎?

+2

爲什麼手動?如果你在excel文件中有數百條記錄,你可以自動完成整個事情。 – Rei

+0

我想上傳到的系統不屬於我。尋找替代品。 – Saariko

+1

所有更自動化的理由。看到我的答案。 – Rei

回答

1

僅當您嘗試上傳的系統提供此類功能時,表單填充功能纔有可能。 即使這樣做,它也只是遠離真正手動輸入數據的一步,所以我建議避免它。 數百條記錄需要很長時間。

如果你的數據源是一個excel文件,你可以自動完成整個上傳過程。 只需讀取excel文件,逐個處理相關行,爲每個行發送POST請求。

這裏是PHP的範例:

//open xlsx file 
$simple = new SimpleXLSX('power-mosfet.xlsx'); 

//get rows from the first worksheet 
$rows = $simple->rows(1); 

//process specific lines (starts from 0) 
$fromLine = 2; 
$toLine = 8; 
for($i = $fromLine; $i<$toLine; $i++){ 
    //select relevant values 
    $data = [ 
     'name' => $rows[$i][0], //column 1 
     'vdss' => $rows[$i][1], //column 2 
     'rdson' => $rows[$i][2], //column 3 
    ]; 

    //send the data in a post request 
    $ch = curl_init('http://example.com/form'); 
    curl_setopt($ch, CURLOPT_POST, true); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_exec($ch); 
    curl_close($ch); 
} 

如果PHP是不是在你的駕駛室,只使用一種編程語言,是。 這個概念是一樣的。

0

你可以寫一個瀏覽器擴展來處理數據導入,表單域的水化和最終的提交;)