Jump to content

Archived

This topic is now archived and is closed to further replies.

may

PHP does not REQUEST form value

Recommended Posts

Hello,

i have got this proble relating to PHP and javascript. I have a form in which there is a field "fee". After filling in the form , the user clicks he button to calculate fee and then this field populates thru javascript.

the problem is that since i havent written any value for this explicitly but assigning it value thru javascript, i m getting an error while retrieving it thru the $_REQUEST function.

Heres the code i m using:

<input name="fee" type="text" id="fee" size="10" disabled="disabled" /></td>
      </tr>
      <tr>
        <td colspan="4"><div align="center">
          <input type="button" name="calculate" value="Calculate Total" onclick="return calcTotal()"/>

and the javascript is:
function calcTotal(){
var group=document.form1.group.options[document.form1.group.selectedIndex].value;
var county=document.form1.county.options[document.form1.county.selectedIndex].value;
var county_price=(document.form1.county_price.value);
var total=0;
var url=document.form1.url.value;
var url_price=document.form1.url_price.value;

if(url=="")
url_price=0;

if(county=="" && group==""){
alert("Please select a County or a Group to post events to");
document.form1.county.focus();
return false;
}

if(county!="" && group!=""){
alert("You can select only a County OR a Group to post events to");
document.form1.county.focus();
return false;
}
if(group!=""){
str=group.split("/");
total=parseInt(str[1])+ parseInt(url_price);
document.form1.fee.value=total;
return true;
}

if(county!=""){

total=parseInt(county_price)+parseInt(url_price);
document.form1.fee.value=total;
return true;
}

}  

I have tried requesting other values for fee variable and it works fine , the problem is that when i retrieve the value of fee from the form  it gives an error , that my var is not defined.

Help me solve this problem.

Share this post


Link to post
Share on other sites
OK.. try this

set fee as a hidden field that is NOT disabled. Replace

<input name="fee" type="text" id="fee" size="10" disabled="disabled" />

with

<span id="dis_fee"></span>

and alter this...

if(group!=""){
        str=group.split("/");
        total=parseInt(str[1])+ parseInt(url_price);
        document.form1.fee.value=total;
        return true;
      }
 
  if(county!=""){
       
        total=parseInt(county_price)+parseInt(url_price);
        document.form1.fee.value=total;
      return true;
  }


to

if(group!=""){
        str=group.split("/");
        total=parseInt(str[1])+ parseInt(url_price);
        document.form1.fee.value=total;
        document.getElementById('dis_fee').innerHTML = "£ " + total;
        return true;
      }
 
  if(county!=""){
       
        total=parseInt(county_price)+parseInt(url_price);
        document.form1.fee.value=total;
        document.getElementById('dis_fee').innerHTML = "£ " + total;
      return true;
  }

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.