Jump to content


Photo

PHP does not REQUEST form value


  • Please log in to reply
2 replies to this topic

#1 may

may
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 20 August 2006 - 10:20 PM

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.


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 August 2006 - 01:19 AM

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;
  }

follow me on twitter @PHPsycho

#3 may

may
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 August 2006 - 09:34 PM

Thanks for the help :)
problem is solved




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users