• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Set a drop down value with a passed URL variable

Set a drop down value with a passed URL variable 11 years 8 months ago #24668

  • martinp
  • martinp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
I've had a look at the following KB article

www.rsjoomla.com/support/documentation/v...can-i-catch-it-.html

and have tried to adapt it so that I can use it to set the value in a drop down box, help? the drop-down doesn't have a Default value field/attribute that I can find

Any assistance greatly appreciated...
Joomla 2.5.8
RSForm! Pro 1.4.0
The administrator has disabled public write access.

Set a drop down value with a passed URL variable 11 years 8 months ago #24706

Please feel free to use this script in the Items area of your dropdown field:

//<code>
$items = array();
$items[0] = "10|First Item";
$items[1] = "25|Second Item";
$items[2] = "random value|Third Item";

$parameter = JRequest::getVar('myparameter');
foreach($items as &$item)
{
$parts = explode("|", $item);
if($parts[0] == $parameter)
$item .= "[c]";
}
return implode("\n", $items);
//</code>

... which will select the value passed as myparameter in the URL.

For example accessing the form with myparameter=random value, will cause the "Third Item" option to be selected.

To add more items to the Dropdown list, simply use the following syntax:

$items[n] = "value|Label";

... and remember that the numbering starts from 0.

You can also omit a value in your item declaration, for example:

$items[n] = "My Label";

... however in this case you will need to access the form with myparameter=My Label in order for the option to be selected.
Please remember that my responses aren't considered customer support, to receive customer support please submit a new customer support ticket, and we will gladly assist you.

Best Regards,
Cristian Nicolae.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!