Jump to content

PHP does not REQUEST form value


may

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.
Link to comment
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;
  }
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.