小编Moh*_*ava的帖子

无法在表<td>单元格中插入图像

我正在尝试为我的网站编写一个购物车,我想为每个项目显示一个表格,包括部分#,名称,数量,价格和一个小图像.除了图像之外,一切都显示得很好,图像出现在桌子的外面(上方),而不是放在我放置它的单元格中.这是代码:

//create a table for the items in the cart
 print("<table class='cart_table'>");
 print("<tr class='first_row'>
        <td>&nbsp;Item No.&nbsp;</td>
        <td>&nbsp;Item Name&nbsp;</td>
        <td>&nbsp;Quantity&nbsp;</td>
        <td>&nbsp;Price&nbsp;</td>
        <td>&nbsp;Image&nbsp;</td>
    </tr>");
//for each item in the cart
foreach ($_SESSION['cart'] as $value) {

    //create a new product object for the item
    $product = new LG_Product($_SESSION['cart'][$i]['item']);
    print("<tr>");
    print("<td>&nbsp;" . $product->itemID . " </td>");
    print("<td>&nbsp;" . $product->productName . " </td>");
    print("<td>&nbsp;" . $_SESSION['cart'][$i++]['qty'] . " </td>");
    print("<td>&nbsp;$" . $product->productPrice . " </td>" );
    print("<td>" . $product->showPrimaryImage('small') . "</td>");
    print("</tr>");
}
//end the …
Run Code Online (Sandbox Code Playgroud)

html php

0
推荐指数
1
解决办法
429
查看次数

使用jquery动态创建html元素

我需要一种方法来解决这个问题.live()在我使用的jQuery 1.9中被删除.所以现在我不知道如何动态地将元素添加到文档对象模型树中.

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Trying dynamic adding</title>
        <style>

            body {
                margin:10%;
            }
            #cool {
                border:5px solid red;
            }
            .fool {
                background-color:red;
                width:100px;
                height:100px;
                border:1px solid green;
            }
            .lol {
                background-color:yellow;
            }

        </style>
        <script src="jquery.js"></script>
        <script>

        $(document).ready(function(){
            alert("Application has been started");
            $('#hool').addClass("lol");
            $('#create').click(function(){
                alert("Element created here");
                var a=$('#cool');
                b="<div class='fool'></div>";
                a.append(b);
                alert("Element created");
                var c=$('.fool');
                c.addClass("lol");
            });
            $('.lol').click(function(){
                alert("New elements are good to go");
                $('.lol').css("background-color","teal");
            });
            function hello(){
                alert("welcome");
            }
        });
        function hello(){ …
Run Code Online (Sandbox Code Playgroud)

html javascript css scripting jquery

0
推荐指数
1
解决办法
520
查看次数

C#如何遍历子列表中的所有列表?

所以我已经停止了这个问题,我无法想到哪个解决方案,它目前逃避了我的想法,我认为我在另一个项目上做了同样的事情,但我丢失了文件..

事实上,我正在编写一个具有一个答案行的对话系统,以及最多3个问题行,每个问题行在点击时都有另一个答案行,可以提出更多问题.

目标是能够建立一个对话系统,可以根据需要提供尽可能多的答案和问题.

但我不知道如何迭代它们,如果它是一个固定的数字,我可以为每个问题做一个for循环,但事实并非如此,我坚持下去!

以下代码是固定数量的ONE问题及其答案和另一个问题列表的示例:

for(int i = 0; i < dialogGiver.dialogLines.Count; i++)
{
    EditorGUILayout.LabelField("Line " + i, EditorStyles.boldLabel);

    dialogGiver.dialogLines[i].line = EditorGUILayout.TextField("Question", dialogGiver.dialogLines[i].line);
    dialogGiver.dialogLines[i].answer = EditorGUILayout.TextField("Answer", dialogGiver.dialogLines[i].answer);

    for (int e = 0; e < dialogGiver.dialogLines[i].dialogLines.Count; e++)
    {
        EditorGUILayout.LabelField("Line " + i + "/ Line " + e, EditorStyles.boldLabel);
    }
}
Run Code Online (Sandbox Code Playgroud)

所以,我如何使该循环查找与DialogLine(以及DialogLine中的DialogLine子)一样多的子问题和子行.

这是DialogLine类:

public class DialogLine
{
    public string line;
    public string answer;

    /// <summary>
    /// This will enable the dialog giver to continue speaking of the same theme (use for …
Run Code Online (Sandbox Code Playgroud)

c# loops dialog list infinite

0
推荐指数
1
解决办法
99
查看次数

WPF:C#如何获取Listbox的选定值?

我正在尝试获取列表框的选定值.当我实际尝试时,LstGroup1.SelectedItem我得到了值{ BoothID = "4", BoothName = "HP" },即使我试图从LstGroup1.SelectedValue输出中得到的值是相同的.现在我想获取BoothID即预期的输出4但是我无法获得.

我的ListBox名字是LstGroup1.

public List<object> BoothsInGroup1 { get; set; }
// Inside the Constructor 
BoothsInGroup1 = new List<object>();
//After Fetching the value add 
BoothsInGroup1.Add(new { BoothID = da["BoothID"].ToString(), BoothName = da["BoothName"].ToString() });

//Now here I get 
var Booth = (LstGroup1.SelectedItem);
//Output is { BoothID = "4", BoothName = "HP" }

// Expected Output 4
Run Code Online (Sandbox Code Playgroud)

建议我怎么做.


编辑

public partial class VotingPanel …
Run Code Online (Sandbox Code Playgroud)

c# wpf listbox

-1
推荐指数
1
解决办法
2万
查看次数

单选按钮onclick表单提交到两个不同的页面操作在Firefox中不起作用

这是onclick单选按钮表单提交的代码,当单击到不同的单选按钮表单操作时应该更改.这段代码在chrome和opera中正常工作,但它在firefox中不起作用.这是表单页面.请帮忙在firefox中运行代码.

<form action="" method="post" name="form1">
    <ul class="list-group">
        <li class="list-group-item">
            <div class="radio">
                <label>
                    <input type="radio" name="optradio" value="yes" onclick="this.form.submit()">
                        <span style="margin-left:40px"></span>
                        <img src="../../pum/PayUMoney_logo.png">
                </label>
            </div>
        </li>
        <li class="list-group-item">
            <div class="radio">
                <label>
                    <input type="radio" name="optradio" value='no' onclick="this.form.submit()" >
                    <span style="margin-left:40px"></span>
                    <img src="../../pum/atom_logo_1.png" style=" height: 35px; width: 163px;">
                </label>
            </div>
        </li>
    </ul>
</form>
<script type="text/javascript">

jQuery(document).ready(function($) 
{
    var form = $('form[name="form1"]'),
    radio = $('input[name="optradio"]'),
    choice = '';
    radio.change(function(e) 
    {
        choice = this.value;
        if (choice === 'yes') 
        {
            form.attr('action', 'hello.php');
            form.attr('target,_'blank');
        } 
        else 
        {
            form.attr('action', …
Run Code Online (Sandbox Code Playgroud)

javascript php

-1
推荐指数
1
解决办法
564
查看次数

如何将字符串打印到数组

当单击"打印"按钮时,我需要将这些名称打印到输出标签上.现在当我点击按钮打印名称时,会弹出3行,说明System.String[].如何打印这些名称而不是System.String[]消息?谢谢!

string[] names = new string[] {"Kevin", "Anthony", "Mike", "Allan" };
private void button1_Click(object sender, EventArgs e)
{
    //taverse the array and dispalay the scores into the label
    string output = "";
    for(int i=0;i<=names.Length; i++)
    {
        output = output + names + "\n";
    }
    displayLabel.Text = output;
}
Run Code Online (Sandbox Code Playgroud)

c# arrays

-1
推荐指数
1
解决办法
75
查看次数

将时间传递给C#中的方法

Program上课和GetDateAndTime上课有两节课.我在GetDateAndTime课堂上得到的时间,我想把时间花在我的主要方法上.我可以把时间从我的问题中解决,GetDateAndTime但是当我把时间传递回program课堂时,我得到00:00:00而不是18:00:00.我从配置文件中抽出时间.

我的代码如下

配置文件

<appSettings>
    <add key="StartTime" value="18:00:00" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)

计划类

private static DateTime t;
static void Main(string[] args)
{
    DateTime day=DateTime.Now;
    GetDateAndTime.CheckDays(day, t);
}
Run Code Online (Sandbox Code Playgroud)

GetDateAndTime类

public static DateTime CheckDays(DateTime day, DateTime t)
{
    var startTimeString = ConfigurationSettings.AppSettings["StartTime"];
    t = DateTime.Parse(startTimeString);
    t.ToString("HH:mm:ss");
    Console.WriteLine(t.ToString("HH:mm:ss"));
    return day;
}
Run Code Online (Sandbox Code Playgroud)

c# methods datetime

-3
推荐指数
1
解决办法
587
查看次数

标签 统计

c# ×4

html ×2

javascript ×2

php ×2

arrays ×1

css ×1

datetime ×1

dialog ×1

infinite ×1

jquery ×1

list ×1

listbox ×1

loops ×1

methods ×1

scripting ×1

wpf ×1