English 中文(简体)
缩略语 我怎么能以动态方式将热点名称/接触点与各自的三重类型联系起来? [闭门]
原标题:PHP/HTML form: How can I properly associate dynamically created horse name/accessories with respective type of trim? [closed]
  • 时间:2023-06-03 22:37:55
  •  标签:
  • php
  • html
Closed. This question needs details or clarity. It is not currently accepting answers.

我不敢清楚解释这一点。 我拥有一个网络,可以追踪一个路子,即一个游子把鞋放在或小块。 当游艇更新时,游艇可以选择多少匹马。 视园区/鞋群数量而定,将确定有多少科室。 每一节都与游泳者三肢/od的每个具体大鼠有关。 因此,美元_POST[数量]。 现在,每节/每段都可以选择进入名字。 游泳者必须进入三肢(三肢、前鞋、全鞋等)。 然后,游轮可以选择他是否使用稻子、焊接器、岩石器、碎片或包装。 或者这里的任何计算。

如今,如果越权者选择不输入一匹马的名称或任何通道,那么,就会有人居住“POST[ horse ][e_trim]美元,但“POST[ horse ][horse_name]和_POST[horse ][accessories]美元将是空白的。

如今,在第二批三重/三重荷尔子的第二节中,越野者可以进入马匹的名字,选择“前南阵线”的类型,并添加通道。

当提交表格时,“POST[horse ][类型_trim]将有两个阵列条目,而“POST[ horse ][horse_name]美元将只有一个条目,“POST[ ][联系人]”的美元将有两个条目。

在下文中,你将看到一个单一名称、两种名称:母子和两个附件。 荷尔语——名称Taco应当与前线_shoes_ur CH:135和Pads和Wedges联系起来,而“母体:40”这一类型是单独存在的。

这里是一页一米工作的屏幕。 也许这将有助于把我所说的话集中起来。

Screen shot of my page I hope this helps clear up what I m needing.

我的表格中包含三个部分。 这些部门是动态的。 该组的第一个选择要素是任择性的,第二组需要,第三组是任择性的。 我的名字如下:

First Select Element: name="horse[horse_name][]" (Optional) <-- Input field
Second Select Element: name="horse[type_trim][]" (Required) <-- Select Element
Third Select Element: name="horse[accessories][]" (Optional) <-- Select Element Multiple

为测试目的,我对该科进行了两次编辑。

在第一节中,马匹的名字是Taco。 第一季度选择“全程”和第三项选择要素一留下空白。

关于第二节,我把马匹的名字命名为酋长。 我选择了“阵线”,第三个选择要素是:我选择了Pads和Wedges。

问题在于,我无法说明哪类可怕的名字和接触点与三重类型有关。 如果我离开马匹的名字空白,那么马匹将使用稻子,并用哪一种三米连接起来?

在提交表格时,我确实是var($_POST),我收到以下法典:

array(9) { 
    ["cID"]=> string(36) "MTA6U2FsdCBmb3IgVVJMIEVuY29kZQ%3D%3D" 
    ["num_horses"]=> string(1) "2" 
    ["horse"]=> array(3) { 
        ["horse_name"]=> array(2) { 
            [0]=> string(5) "Taco" } <-- This horse needs to be associated with front_shoes_urethane:135
        ["type_trim"]=> array(2) { 
            [0]=> string(7) "trim:40" 
            [1]=> string(24) "front_shoes_urethane:135" } 
        ["accessories"]=> array(2) { <-- this accessories needs to be associated with the horse Taco and front_shoes_urethane:135
            [0]=> string(7) "pads:15" 
            [1]=> string(9) "wedges:15" } } 
    ["date_trimmed"]=> string(10) "2023-06-03" 
    ["next_trim"]=> string(10) "2023-07-08" 
    ["trim_time"]=> string(8) "09:00:00" 
    ["payment_amount"]=> string(3) "205" 
    ["receipt"]=> string(1) "1" 
    ["submit"]=> string(8) "Add Date" 
 }

这里是我与以下各方合作的守则:

if(!empty($_POST[ quantity ]) && is_numeric($_POST[ quantity ])){ <-- This is what makes each section dynamic
    
        $trimList =   ;
        $serviceOptions =   ;
        $accOptions =   ;
        $services = [
             trim  => [$userResult->trim, Full Trim ],
             front_shoes_urethane  => [$userResult->front_shoes_urethane, Front Urethane Shoes ],
             full_shoes_urethane  => [$userResult->full_shoes_urethane, Full Urethane Shoes ],
             reset_front_shoes_urethane  => [$userResult->reset_front_shoes_urethane, Reset Front Urethane Shoes ],
             reset_full_shoes_urethane  => [$userResult->reset_full_shoes_urethane, Reset Full Urethane Shoes ],
            
             front_shoes_steel  => [$userResult->front_shoes_steel, Front Steel Shoes ],
             full_shoes_steel  => [$userResult->full_shoes_steel, Full Steel Shoes ],
             reset_front_shoes_steel  => [$userResult->reset_front_shoes_steel, Reset Front Steel Shoes ],
             reset_full_shoes_steel  => [$userResult->reset_full_shoes_steel, Reset Full Steel Shoes ],
            
             front_shoes_aluminum  => [$userResult->front_shoes_aluminum, Front Aluminum Shoes ],
             full_shoes_aluminum  => [$userResult->full_shoes_aluminum, Full Aluminum Shoes ],
             reset_front_shoes_aluminum  => [$userResult->reset_front_shoes_aluminum, Reset Front Aluminum Shoes ],
             reset_full_shoes_aluminum  => [$userResult->reset_full_shoes_aluminum, Reset Full Aluminum Shoes ],
            
             front_shoes_special  => [$userResult->front_shoes_special, Specialized Front Shoes ],
             full_shoes_special  => [$userResult->full_shoes_special, Specialized Full Shoes ],
             reset_front_shoes_special  => [$userResult->reset_front_shoes_special, Reset Specialized Front Shoes ],
             reset_full_shoes_special  => [$userResult->reset_full_shoes_special, Reset Specialized Full Shoes ]
        ];
        $accessories = [
             pads  => $userResult->pads,
             packing  => $userResult->packing,
             wedges  => $userResult->wedges,
             rockers  => $userResult->rockers,
             clips  => $userResult->clips
        ];
        
        foreach($services as $key => $value){
            if(empty($value[0])) continue;
            $serviceOptions .= "<option value="{$key}:{$value[0]}">{$value[1]}</option>";
        }
        
        foreach($accessories as $key => $value){
            if(empty($value)) continue;
            $accOptions .= "<option value="{$key}:{$value}">".ucwords($key)."</option>";
        }
        
        for($i=1; $i<=$_POST[ quantity ]; $i++){
            $id =  _ .$i;
            $trimList .= "
<div class="w3-row w3-padding">
    <div class="w3-col m6">
        <label for="type_trim{$id}">Type of Trim for horse {$i}:</label>
    </div>
    <div class="w3-col m6">
        <div class="w3-padding-small">
            <input id="horse_name{$id}" class="w3-input w3-border w3-border-black" name="horse[horse_name][]" placeholder="Horses Name/Description: Optional">
        </div>
        <div class="w3-padding-small">
            <select id="type_trim{$id}" class="w3-input w3-border w3-border-black addCost" name="horse[type_trim][]" onChange="getPaymentAmount(this);" required>
                <option value="0">Select Service</option>
                {$serviceOptions}
            </select>
        </div>";
        
            if(!empty($accOptions)){
                $trimList .= "
            <div class="w3-padding-small">
                Select Accessories: <span class="w3-small">Optional</span>
                <select id="accessories{$id}" class="w3-input w3-border w3-border-black addCost" name="horse[accessories][]" onChange="getPaymentAmount(this);" multiple>
                    <option value="0">Select Accessories</option>
                    {$accOptions}
                </select>
            </div>";
            }
        
        $trimList .= "
    </div>
</div>";            
        }
        echo json_encode([ result  => 1,  trimList  => $trimList]);
        exit;
    }

我试图将姓名改为:

name="horse[horse_name[]]" <-- Did not work
name="horse_name[]" <-- Still does not associate with the type trim
name="horse[horse_name][$i][] <-- This produced the wrong results

这是否可行?

最新资料:在我富有活力的基础上,我补充说:

name="horse{$id}[horse_name][]"
name="horse{$id}[type_trim][]"
name="horse{$id}[accessories][]"

并且我正在看到这为我所需要的方法。 解决这一难题的唯一问题是我不知道有多少美元。 我将坐在PHP一边。

SECOND UPDATE:我去做工作,但我不得不从php方面而不是在超文本方面工作。 越权投入的数量告诉我,有多少美元_POST[ horse_nth] 我已经。 因此,这只是通过它们和获取我所需要的信息的问题。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签