Can you nest html forms?

前端 未结 20 3093
悲&欢浪女
悲&欢浪女 2020-11-21 04:56

Is it possible to nest html forms like this

so

20条回答
  •  臣服心动
    2020-11-21 05:16

    Another way to get around this problem, if you are using some server side scripting language that allows you to manipulate the posted data, is to declare your html form like this :

    If you print the posted data (I will use PHP here), you will get an array like this :

    //print_r($_POST) will output :
        array(
        'a_name' => 'a_name_value',
        'a_second_name' => 'a_second_name_value',
        'subform' => array(
          'another_name' => 'a_name_value',
          'another_second_name' => 'another_second_name_value',
          ),
        );
    

    Then you can just do something like :

    $my_sub_form_data = $_POST['subform'];
    unset($_POST['subform']);
    

    Your $_POST now has only your "main form" data, and your subform data is stored in another variable you can manipulate at will.

    Hope this helps!

提交回复
热议问题