2 Replies - 935 Views - Last Post: 01 May 2008 - 08:04 AM Rate Topic: -----

#1 chac416  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-January 06

if and radio buttons

Posted 01 May 2008 - 07:42 AM

So I want to return the results of radio buttons selection in php.

I got the code:
  function list_rates( &$d ) {
	  global $vendor_name, $VM_LANG, $shipping_rate;
	  
	  $html = "<strong>".$VM_LANG->_('PHPSHOP_FREE_SHIPPING_CUSTOMER_TEXT')."</strong>&nbsp;";
	  $html .= "<input type=\"radio\" name=\"shipping_rate_id\" value=\"free_shipping|$vendor_name|".$VM_LANG->_('PHPSHOP_FREE_SHIPPING')."|0|1\" checked=\"checked\" />";

	  $html .= "<strong><br />You can still upgrade to express shipping ($6.00)";
	  $html .= "<input type=\"radio\" name=\"shipping_rate_id\" value=\"express_shipping\" />";
	  
	  $html .= "<strong>&nbsp;&nbsp;or same day shipping ($12.00)";
	  $html .= "<input type=\"radio\" name=\"shipping_rate_id\" value=\"sameday_shipping\" />";
	  
	  echo $html;
	  return True;
	}



Now, if the first radio button is checked, i want to return 0. If the second was checked then i want to return 6 and return 12 for the 3rd radio button selection. The if and return has to be done in another function here:

   function get_rate( &$d ) {
   
   		if ($selected_radio == 'free_shipping') {
			$shipping_rate = 0; }
   		if ($selected_radio == 'express_shipping') {
			$shipping_rate = 6; }
   		if ($selected_radio == 'sameday_shipping') {
			$shipping_rate = 12; }
   
		return $shipping_rate;		
   } 



I tried this if, but it didn't work. I'm not an expert in php, so I am still learning :)

My basic question is: how to? :)

Is This A Good Question/Topic? 0
  • +

Replies To: if and radio buttons

#2 MitkOK  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 32
  • View blog
  • Posts: 403
  • Joined: 09-August 07

Re: if and radio buttons

Posted 01 May 2008 - 07:53 AM

If you're using POST method ...

   function get_rate( &$d ) {
   
   		if ($_POST['shipping_rate_id'] == 'free_shipping') {
			$shipping_rate = 0; }
   		if ($_POST['shipping_rate_id'] == 'express_shipping') {
			$shipping_rate = 6; }
   		if ($_POST['shipping_rate_id'] == 'sameday_shipping') {
			$shipping_rate = 12; }
   
		return $shipping_rate;		
   } 

[/quote]
Was This Post Helpful? 1

#3 chac416  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-January 06

Re: if and radio buttons

Posted 01 May 2008 - 08:04 AM

No, I am not using the POST method.

I am editing Joomla/Virtuemart module and I see no POST or form anywhere in the files. hmmm
any other method?

---
EDIT:
it actually work out well. haha. thanks a bunch dude

This post has been edited by chac416: 01 May 2008 - 08:15 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1