Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法按照JavaScript中的代码获取所需的输出_Javascript_Jquery_Html_Css - Fatal编程技术网

无法按照JavaScript中的代码获取所需的输出

无法按照JavaScript中的代码获取所需的输出,javascript,jquery,html,css,Javascript,Jquery,Html,Css,在网页上显示seatlayout的html代码 我们将使用JavaScript在#place元素中添加座位。 为了使其通用化,使用了设置对象: 行数:座椅总行数 cols:每排座位总数 rowCssPrefix:将用于使用(rowCssPrefix+行数)css类自定义行布局 colCssPrefix:将用于使用(colCssPrefix+列号)css类自定义列 seatWidth:座椅宽度 seatHeight:座椅高度 seatCss:css座椅等级 selectedseatcs:已预订座位

在网页上显示seatlayout的html代码

我们将使用JavaScript在
#place
元素中添加座位。 为了使其通用化,使用了
设置
对象:

行数
:座椅总行数

cols
:每排座位总数

rowCssPrefix
:将用于使用(
rowCssPrefix
+
行数
)css类自定义行布局

colCssPrefix
:将用于使用(
colCssPrefix
+列号)css类自定义列

seatWidth
:座椅宽度

seatHeight
:座椅高度

seatCss
:css座椅等级

selectedseatcs
:已预订座位的css类别

选择座位css
:选定座位的css类别

init
方法用于绘制座椅布局。已预订座位数组将作为此方法的参数传递

<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="javascript" type="text/javascript">


<script>
   
     var   settings = {
           rows: 5,
           cols: 15,
           rowCssPrefix: 'row-',
           colCssPrefix: 'col-',
           seatWidth: 35,
           seatHeight: 35,
           seatCss: 'seat',
           selectedSeatCss: 'selectedSeat',
           selectingSeatCss: 'selectingSeat'
       };
<!--rows: total number of rows of seats.
    cols: total number of seats in each row.
    rowCssPrefix: will be used to customize row layout using(rowCssPrefix + row number) css class.
 colCssPrefix: will be used to customize column using (colCssPrefix + column number) css class.
    seatWidth: width of seat.
    seatHeight: height of seat.
    seatCss: css class of seat.
    selectedSeatCss: css class of already booked seats.
    selectingSeatCss: css class of selected seats.->
  <!-- init method is used to draw seats layout. Already booked seats array will be passed as argument of this method.->
    var init=function(reservedSeat) {
                 
            var str = [], seatNo, className;
              for (i = 0; i < 5; i++) {
                
                 for (j = 0; j < 5; j++) {
                         
                    seatNo = (i + j * settings.rows + 1);                                              
                    className = settings.seatCss + ' ' +    settings.rowCssPrefix + i.toString()    + ' ' + settings.colCssPrefix +   j.toString();                             if ($.isArray(reservedSeat) &&  $.inArray(seatNo, reservedSeat) != -1) {
              className += ' ' + settings.selectedSeatCss;
                    }
                    str.push('<li id="' + className + '"' +
                              'style="top:' + (i *   settings.seatHeight).toString() + 'px;left:' + (j *   settings.seatWidth).toString() + 'px">' +
                              '<a title="' + seatNo + '">' + seatNo +   '</a>' +
                              '</li>');
                }
              }
            $('#place').html(str.join(''));
        }; 
        //case I: Show from starting
        //init();

        //Case II: If already booked
       
        var bookedSeats = [5, 10, 25];

        init(bookedSeats);
    
</script>
<!--  we need to add style -->
<style>
#holder{    
height:200px;    
width:550px;
background-color:#F5F5F5;
border:1px solid #A4A4A4;
margin-left:10px;   
}
#place {
position:relative;
margin:7px;
}
#place a{
font-size:0.6em;
}
#place li
{
list-style: none outside none;
position: absolute;   
}    
#place li:hover
{
background-color:yellow;      
} 
#place seat{
background-color: blue;
background:url("seat.gif") no-repeat scroll 0 0 transparent;*/
height:33px;
width:33px;
display:block;   
}
#place.selectedSeat
{ 

background-image:url("seat.gif");          
}
#place.selectingSeat
{ 
background-image:url("seat.gif");        
}
#place .row-3, #place .row-4{
margin-top:10px;
}
#seatDescription li{
verticle-align:middle;    
list -style: none outside none;
padding-left:35px;
height:35px;
float:left;
}
</style>
</head>

<body>
<h2> Choose seats by clicking the corresponding seat in the layout        below:</h2>
<div id="holder"> 
    <ul  id="place">
    </ul>    
 <!-- We will add seats in “#place” element using javascript.-->
 </div>
 <div style="float:left;"> 
 <ul id="seatDescription">
    <li style="background:url('seat.gif') no-repeat scroll 0 0  transparent;">Available Seat</li>
    <li style="background:url('seat.gif') no-repeat scroll 0 0  transparent;">Booked Seat</li>
     <li style="background:url('seat.gif') no-repeat scroll 0 0 transparent;">Selected Seat</li>
   </ul>
   </div>
     <div style="clear:both;width:100%">
     <input type="button" id="btnShowNew" value="Show Selected Seats" />       <input type="button" id="btnShow" value="Show All" />  
     <input type="button" id="b1" value="Seatlayout"/>         
    </div>
   </body>
  </html>

变量设置={
行:5,
科尔斯:15,
rowCssPrefix:“行-”,
colCssPrefix:'col-',
西雅图:35,
座位号:35,
座位:'座位',
SelectedSeatCS:“selectedSeat”,
selectingSeatCss:“selectingSeat”
};
#持有人{
高度:200px;
宽度:550px;
背景色:#F5;
边框:1px实心#A4A4A4;
左边距:10px;
}
#放置{
位置:相对位置;
利润率:7px;
}
#放置{
字号:0.6em;
}
#地点李
{
列表样式:无外无;
位置:绝对位置;
}    
#地点:悬停
{
背景颜色:黄色;
} 
#就座{
背景颜色:蓝色;
背景:url(“seat.gif”)无重复滚动0透明*/
高度:33像素;
宽度:33px;
显示:块;
}
#所选座位
{ 
背景图片:url(“seat.gif”);
}
#地点选择座位
{ 
背景图片:url(“seat.gif”);
}
#地点。第三排,#地点。第四排{
边缘顶部:10px;
}
#座位描述李{
垂直排列:中间;
列表样式:无外无;
左侧填充:35px;
高度:35px;
浮动:左;
}
通过单击以下布局中的相应座位来选择座位:
    可用座位
  • 预订的座位 所选座位不重复滚动0 0透明;“>

此代码有什么问题?为什么我没有得到想要的输出很难从这段代码中猜出来,你能把你得到的错误贴出来吗?如果你能把你的代码转储到JSFIDLE中,让我们知道你的期望是什么,那就太好了。展示这个问题的一个实例总是很好的,我希望输出可以像在空盒子里找座位一样,嗯,就像我说的,通过分析超过20行的代码很难可视化输出。因此,如果您可以创建一个JSFIDLE,就很容易理解这个问题。将此脚本引用放在头标记内
。要了解更多信息,可以查看此JSFIDLE,