English 中文(简体)
将多功能阵列添加到<投入类型=盒式>
原标题:Adding multidiemnsionall array to <input type=checkbox>
  • 时间:2010-12-03 18:05:47
  •  标签:
  • html

Ok,

I have my form something like this
(html format)

<input type="checkbox" name="opt[]" value="php echo $option[ optionname ]?>

I m处理方式高于选择,目前只有选择名称。

Now I want to add optionprice as well.As every option users select has a price.

因此,它应该像这样提出。

<input type="checkbox" name="opt[][]" value="php echo $option[ optionname ] $option[ optionprice ] >
问题回答

否 我完全理解你的问题。 投入部分有一个名称和一个价值。 你可以允许输入多维数据,并将数据输入服务器。 但是,你们应当考虑该“倡议”设计的用户经验。

如果你想办法将元数据放在正文中,则看上去。 这使你能够将数据输入元件标记并轻易检索。 这里的联系

http://api.jquery.com/data/

希望这一帮助。

页: 1

Given that I understand your question correctly: if you know the price already for each option, you don t need to submit it via the form. You can just match the selected option with the price on your backend.

否则,通过POST发送多维阵列的一种方式是:

<!-- product A with 2 prices --> 
<input type="checkbox" name="opt[productA][]" value="<?php echo $option[ productA ][ price1 ]; >
<input type="checkbox" name="opt[productA][]" value="<?php echo $option[ productA ][ price2 ]; >

<!-- product B with 3 prices --> 
<input type="checkbox" name="opt[productB][]" value="<?php echo $option[ productB ][ price1 ]; >
<input type="checkbox" name="opt[productB][]" value="<?php echo $option[ productB ][ price2 ]; >
<input type="checkbox" name="opt[productB][]" value="<?php echo $option[ productB ][ price3 ]; >




相关问题
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!

热门标签