你好
1. 我想问下面代码中switch($product_id) 这里product_id与<input type="radio" name="product_id" id="product_id" 代码中的product_id是否是同一个
2.我想按照switch语句,当用户选择不同的产品时,根据product_id的value来传相对应的charge,就是product_id与charge按照下面代码中的函数处理,就是拼成串之后用加密工具进行加密,然后传过去,但我用echo $EncodingTxt;exit; 这个语句却不能显示 EncodingTxt的值,难道是函数处理过程中出了问题还是switch中的$product_id 与下面的<input type="radio" name="product_id" id="product_id"  这里的product_id不一样导致不输出。
<?php
switch($product_id){
case '20302000':
$charge = 1800;
break;
case '20301000':
$charge = 1000;
break;
}
$EncodingTxt = calling($product_id,$charge);
function calling($product_id,$charge) {
$EncodingValue = "";
$EncodingValue = "product_id=". $product_id .";charge=". $charge;

$EncodingTxt = Encoding($EncodingValue);
return $EncodingTxt;
}
function Encoding($EncodingValue){
$cmd = sprintf("jiami.exe W E \"%s\" ", $EncodingValue); 
$EncodingTxt = exec($cmd);
return $EncodingTxt;
}echo $EncodingTxt;exit;
?>
<html>
<head>
<title>***</title>
<script type="text/javascript"> 
function testCount(){ 
var count1 = document.getElementById("txt_account").value; 
var count2 = document.getElementById("txt_raccount").value; 
if(count1!=count2){ 
alert("输入的账号不一致,请重新输入"); 
}else{ 
with(document.getElementById("form1")){ 
method="post"; 
action="http://***/abs.asp"; 
submit(); 



</script> 
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onLoad="document.requestfrm.telnumber2.focus();SelCountry(document.requestfrm.area);">
<form id="form1"> 
<table width="374" height="415" border="0" align="center" cellpadding="0" cellspacing="1" style="border:1px solid #000000;">

<tr>
  <td width="35%" align="center" height="50" valign="center"><font size="2.5px" color="#008000">* 充值金额</font></td>
  <td width="65%" valign="bottom" height="50"><label>
<input type="radio" name="product_id" id="product_id" value="20302000" checked /><font size="2.5px">网易一卡通18元100点(18元)</font></label>
<br />
<label>
    <input type="radio" name="product_id" id="product_id" value="20301000"  />网易一卡通10元60点</label>
<br /><label> </td>
</tr>

<tr> 
  <td width="35%" align="center" height="50"><font size="2.5px" color="#008000"> * 需要充值的账户</font> </td> 
  <td width="65%" align="center" height="50"> <input name="txt_account" id="txt_account" size="25" value="" /> </td> 
</tr> 
<tr>    <td align="center"><font size="2.5px" color="#008000">* 重复输入账户</font> </td> 
  <td align="center"> <input name="txt_raccount" id="txt_raccount" size="25" value="" onpaste='return false' oncontextmenu='return fasle' 
                       onkeypress="return!(event.ctrlKey&&(String.fromCharCode(event.charCode=='v')))"/> </font> </td> 
</tr> 
<tr> 
<td height="50" colspan="2" align="center"> 
<input type="button" name="sb_next" class="paysubmit" value="发送" onclick='testCount()' /> </td>
<INPUT TYPE="hidden" NAME="request" VALUE="<? echo($EncodingTxt) ?>">
</tr> 
   
              </table>

解决方案 »

  1.   

    是用这个 $_POST['product_id'] 来获取提交的值吧~~~
      

  2.   

    恩,是的,但是我想在当前这个页面中把<input type="radio" name="product_id" id="product_id" value="  这里的product_id与当前页面中的switch语句相关联,这样就能按照product_id后面那个value值,选择相应的charge,然后对product_id与charge进行加密处理,然后传到abs.asp页面(点击发送按钮的话就从当前页面转到abs.asp页面,而且会带函数的返回值(处理product_id与charge的函数))
      

  3.   

    那我在代码的最前面加上  $product_id = $_POST['product_id']; 这个的话,能获得 <input type="radio" name="product_id" id="product_id" 这里的value值么? 貌似不行,因为form1里会post传到abs.asp页面里,但是我想在本页面中获得<input type="radio" name="product_id" id="product_id" 这里的value(然后找到相应的product_id的charge),然后将相关product_id与charge,一同进行上面的函数处理之后传到abs.asp页面(即点击发送按钮之后跳转到的下一页)
      

  4.   

    这个,AJAX没学过啊,请指教,或yishiwucheng能否留个QQ啥的,请教方便,谢谢