dpnru86024 2014-03-10 17:37
浏览 34
已采纳

如何隐藏动态生成的输入标签和归档

Im using a php mvc. It has a file called view create which gets a specified table from the mysql database and generates a form for it.

How would I hide a specific field and label.

The field is called allowed in the database and when the html is generated its id is input_allowed.

Thanks in advance.

EDIT : The field has been hidden with #input_allowed{display:none;} , but the label (text called allowed , not actually a label , but displayed inside a ) is still showing.

This is the code for the view_create.php file.

<?

    $class_obj=$_REQUEST['class_obj'];

    echo "<p class='p1'>Create new ".$class_obj."</p>";
    if (isset($_REQUEST['post_create']))
    {
        post_create_message($_REQUEST['post_create'],$class_obj);
    }


    echo "<table class=table1><form id=form_create action=".$current_file_name."?here=".$here."&mode=confirm_create&class_obj=".$class_obj." method=post>";

    $w_columns = MyActiveRecord::Columns($class_obj);
    foreach($w_columns as $wcolumns_key => $wcolumns_value)
    {
        if ($wcolumns_key != "id")
        {
            //if($wcolumns_key == "date")
            if(MyActiveRecord::GetType($class_obj,$wcolumns_key) == 'date')
            {
                echo "<tr><td>".$wcolumns_key."<td><input type=text id='input_".$wcolumns_key."' name='input_".$wcolumns_key."' value=''>";
                echo "<td><input type=button value='Set Date' onclick=displayDatePicker('input_".$wcolumns_key."',false,'ymd','-'); >";

                //echo "<tr id='arow'><td>".$wcolumns_key."<td><input type=text id='input_".$wcolumns_key."' name='input_".$wcolumns_key."' value='' datepicker='true' datepicker_format='DD/MM/YYYY'>";
                //echo "<tr><td>".$wcolumns_key."<td><input type=text id='input_".$wcolumns_key."' name='input_".$wcolumns_key."' value='' datepicker='true' datepicker_format='DD/MM/YYYY'><td><div id='aaa'>&nbsp;</div><script>var b = new free_date_picker('b', 'aaa', 'input_".$wcolumns_key."', 1, true, 'en');</script>";




            }
            else
            {

                echo "<tr><td>".$wcolumns_key."<td><input type=text id='input_".$wcolumns_key."' name='input_".$wcolumns_key."' value=''>";
                if (strlen($wcolumns_key)> 2 && !(strpos($wcolumns_key,"_id")===false))
                {
                    //$related_class = substr($wcolumns_key, 0, -3);
                    $related_class = find_relatedclass($wcolumns_key,$foreign_keys);
                    echo "<td><select id='select_".$wcolumns_key."' onChange=javascript:change_obj('".$wcolumns_key."') ><option></option>";

                    foreach ($obj_class = MyActiveRecord::FindBySql($related_class, 'SELECT * FROM '.$related_class.' WHERE id > -1 ORDER BY referred_as') as $obj_attribute => $obj_attr_value)
                    {
                    // echo "<option>".$obj_attribute." - ".$obj_attr_value->referred_as;    // it works, but...

                        echo "<option value='".$obj_attr_value->id."'>".$obj_attr_value->id." - ".$obj_attr_value->referred_as;

                    //echo "(".$wcolumns_key.")";

                         if (strlen($wcolumns_key)> 2 && !(strpos($wcolumns_key,"_id")===false))
                        {
                            // $related_superclass = substr($wcolumns_key, 0, -3);
                            $related_superclass = find_relatedclass($wcolumns_key,$foreign_keys);
                            foreach ($super_obj = MyActiveRecord::Columns($related_superclass) as $super_obj_attribute => $super_obj_value)
                            {
                                if (strlen($super_obj_attribute)> 2 && !(strpos($super_obj_attribute,"_id")===false))
                                {
                                    //$related_supersuperclass = substr($super_obj_attribute, 0, -3);
                                    $related_supersuperclass = find_relatedclass($super_obj_attribute,$foreign_keys);

                                    //$related_superobj = $obj_attr_value->find_parent($related_supersuperclass)->referred_as;
                                    $related_superobj = $obj_attr_value->find_parent($related_supersuperclass,$super_obj_attribute)->referred_as;
                                    //echo "<td>".$obj_value->$obj_attribute.". ".$obj_value->find_parent($related_class,$obj_attribute)->referred_as;


                                    echo " (".$related_superobj.")";
                                }
                            }
                        }
                    }
                    echo "</select >";
                }

            }
        }
    }

    foreach ($join_tables as $jt_key => $jt_value)
    {
        $pos = strpos($jt_value,$here);
        if($pos === false) {
                        // string needle NOT found in haystack
        }
        else {      // string needle found in haystack

            $there = str_replace("_","",$jt_value);
            $there = str_replace($here,"",$there);

            include "view_displayjt.php";
        }
    }


    echo "<tr><td><td><input type=button value='Create new ".$here."' onClick=javascript:confirm_create('form_create');><td><input type=reset >";
    echo "</table></form>";

?>
  • 写回答

1条回答 默认 最新

  • douaikuai2715 2014-03-10 18:59
    关注

    Wrap the text inside a span and give both the span and the input a unique class name (for example, 'hideme'). This way you get a little flexibility when using CSS. If for some reason you can't use a class, adding "display:none" to the span will do the trick.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?