在php中获取选项标记值
我有一个我无法解决的问题。部分原因是我无法用正确的术语解释它。我不熟悉这个问题,很抱歉问了这个笨拙的问题 下面你可以看到我的目标概述 我正在使用Magento CE 1.7.0.2在php中获取选项标记值,php,html,ajax,magento,Php,Html,Ajax,Magento,我有一个我无法解决的问题。部分原因是我无法用正确的术语解释它。我不熟悉这个问题,很抱歉问了这个笨拙的问题 下面你可以看到我的目标概述 我正在使用Magento CE 1.7.0.2 <div id="display"> <?php if (sizeof($final_na)>0) { $i = 0; ?> <select size="5" class="auto-search"
<div id="display">
<?php
if (sizeof($final_na)>0) {
$i = 0;
?>
<select size="5" class="auto-search" style="height:132px;width: 420px;padding:0px;" name="hero">
<?php foreach ($final_na as $key => $value) { ?>
<option style="text-align:center;padding: 5px 0 0;" value="<?php echo $final_na1[$i]; ?>" class="display_box" align="left" onclick="fill('<?php echo $value;?>')">
<?php echo $value; ?>
</option>
<?php $i++; ?>
<?php } ?>
</select>
<?php } ?>
</div>
<label for="description" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Description') ?> :</label>
<textarea name="description" class="required-entry " id="description" rows="5" cols="75" ><?php echo $description?></textarea>
<label for="price" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Price') ?> :</label>
<input type="price" class=" required-entry widthinput" name="price" id="price" value="<?php echo $price?>"/>
您可以通过json将searchbox的值发送到targetfile.php
在单击处理程序中
$.ajax({
url: "targetfile.php",
type: "POST",
dataType : "json",
data: {"hero":searchbox},
success: function(data) {
// something that should happen after success
// data is filled with the output of targetfile.php (should be json)
}
});
执行print\u r($\u POST)在targetfile.php中使用code>查看您得到了什么。
看看firebug的控制台选项卡
我必须将所选值存储在phpIf的一个变量中如果您在
周围有一个
,您可以使用
提交表单,该值将在php中通过$\u POST['hero']
访问。或者,您可以通过ajax从单击功能发送到php。不,我在更多字段后有提交按钮,如果我使用提交按钮,则没有意义。在这之前,我有任何方法,我必须得到这个动态的答案…我没有任何目标文件。。。我只有一个文件。但是,您需要一个文件来处理请求。如果只有一个,您可以选择修改它以正确响应请求,或者创建一个新的来处理请求。
$.ajax({
url: "targetfile.php",
type: "POST",
dataType : "json",
data: {"hero":searchbox},
success: function(data) {
// something that should happen after success
// data is filled with the output of targetfile.php (should be json)
}
});