HTML / JavaScript - 如何将下拉值转换为数组?

时间:2017-07-17 09:33:35

标签: javascript jquery html arrays

我有以下HTML表格(datatable jquery插件):

enter image description here

表格的每一行都有一个带有ID号的input type = "hidden" name = WorkOrderID[]

我希望以数组形式提交图像中标有蓝色和绿色的下拉列表的值,如下所示:

array(         
        0=>    
            [WorkOrderID] : 10    
            [BlueDropdown] : 14    
            [GreenDropdown] : 22,
        1=> 
            [WorkOrderID] : 11    
            [BlueDropdown] : 45    
            [GreenDropdown] : 7,
        2=> 
            [WorkOrderID] : 12    
            [BlueDropdown] : null (in case no value was selected)    
            [GreenDropdown] : 69,
       )

是一名前端开发人员,因此我对HTML和JS的了解基本上是空的。
你能伸出援助之手吗?我需要使用JQuery

完成它

修改 这是我的“代码”到目前为止(抱歉它是一个图像,远程工作,无法复制/粘贴): enter image description here

1 个答案:

答案 0 :(得分:1)

运行以下代码。这可能是你正在寻找的东西。检查控制台输出。检查元素>控制台

TAlgoResult HeavyAlgorithm() {/* Here is algorithm routine */};
QFuture<TAlgoResult> RunHeavyAlgorithmAsync() 
{
    QtConcurrent::run([&](){return HeavyAlgorithm();});
}

// class which calls algo
class AlgoCaller
{
    QFutureWatcher<TAlgoResult> m_future_watcher;
    QDialog*                    mp_modal_dialog;

    AlgoCaller()
    {
        QObject::connect(&m_future_watcher, &QFutureWatcher<void>::finished, 
        [&]()
        {
            mp_modal_dialog->close(); // close dialog when calculation finished
        })
    }

    void CallAlgo() // to be called from main thread
    {
        mp_modal_dialog->show(); // show dialog before algo start
        m_future_watcher.setFuture(RunHeavyAlgorithmAsync()); 
            // start algo in background

        // main thread is not blocked and events can be processed
    }

};