• 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: Show the caption instead of value in email

Show the caption instead of value in email 13 years 1 month ago #12947

  • olia
  • olia's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
It is the site that I work on: canadaexpert.ca/index.php?option=com_k2&...item&id=27&Itemid=41

I wanna to calculate the score of the chosen options.

For example:
I have the radio item like this:
20|radio1
20|radio2
25|radio3
and the dropdown item like this:
10|drop1
15|drop2
15|drop3
and some checkbox like this:
10|check1
10|check2
15|check3
and some fileds like this:
filed1
filed2
filed3

Now, I wanna to calculate the value of these. I found the way that calculates it...
But
I need the caption of selected option of any items in email and submission form.
I need to tell me that the submitter has selected radio1, drop2, check1 and ... and use the value for calculation
The topic has been locked.

Re:Show the caption instead of value in email 13 years 3 weeks ago #13135

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 722
  • Thank you received: 59
Hello,

This can be achieved, but it will require some custom scripting. You could try adding 3 hidden fields to your form then use a custom javascript in order to retrieve the label of the selected radio/dropdown/checkbox option and store them in one of the hidden fields.

For radio groups
function grabDesc(param)
{
	for(i=0;i<document.getElementsByName('form['+param+']').length;i++)
		if(document.getElementById(param+i).checked)
			for(j=0;j<document.getElementsByTagName('label').length;j++)
				if(document.getElementsByTagName('label')[j].getAttribute('for') == param+i)
					document.getElementById('hidden_field1').value = document.getElementsByTagName('label')[j].innerHTML;
 
	alert(document.getElementById('hidden_field1').value);
}

In order to trigger this function for radio groups you will need to use
onclick="grabDesc('field-name');"

For dropdowns
function getDescription(param)
{
var index  = document.getElementById(param).selectedIndex;
var option = document.getElementById(param).options[index];
 
var test = option.text;
document.getElementById('hidden_field2').value = option.text;
alert(document.getElementById('hidden_field2').value);
}

In order to trigger this function for radio groups you will need to use
onchange="getDescription('field-name');"

For checkbox groups
function grabDesc(param)
{
        document.getElementById('hidden_field3').value = '';
	for(i=0;i<document.getElementsByName('form['+param+'][]').length;i++)
		if(document.getElementById(param+i).checked)
			for(j=0;j<document.getElementsByTagName('label').length;j++)
				if(document.getElementsByTagName('label')[j].getAttribute('for') == param+i)
					document.getElementById('hidden_field3').value = document.getElementById('hidden_field3').value + ' ' + document.getElementsByTagName('label')[j].innerHTML;
 
	alert(document.getElementById('hidden_field3').value);
}

The checkbox field will use the same trigger as the radio group.
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 12 years 4 months ago by andreic.
The topic has been locked.

Re:Show the caption instead of value in email 13 years 3 weeks ago #13140

  • swat1
  • swat1's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hello, checked the top two scripts, I have not worked, is there any options then?
The topic has been locked.

Re: Show the caption instead of value in email 12 years 5 months ago #15434

This would be really helpful if it worked. The instructions are incomplete.
The topic has been locked.

Re: Show the caption instead of value in email 12 years 5 months ago #15441

Inconsistent use of color in the code seems to indicate variables, but i can't make any sense out of it.

Specifically i'm trying to use the "dropdown" version of this custom code. Here's the problems i've found with this code:

function getDescription(param)
{
var index = document.getElementById(param).selectedIndex;
var option = document.getElementById(param).options[index];

var test = option.text;
document.getElementById('hidden_field2').value = option.text;
alert(document.getElementById('hidden_field2').value);
}

1 - What's "param"? Is that where the name of the dropdown component i'm trying to capture goes?
2 - You wrote to put "onchange="grabDesc('field-name');""in additional attributes, but maybe you meant "onchange="grabDescription('hidden_field2');"... but it is not clear.
3 - IE's debugger claims "object required" when i change the selection in the dropdown.
4 - what's with the alert? I don't want to pop up the description, i want to display it with {hidden_field2:value} somewhere, but i can't even tell if this scrip will set that hidden_field2 value.
Last Edit: 12 years 5 months ago by geekchick. Reason: ... I'm rude in the morning.
The topic has been locked.

Re: Show the caption instead of value in email 11 years 10 months ago #17551

Hi、

checked the top two scripts, I have not worked, is there any options then?

moser
The topic has been locked.

Re: Show the caption instead of value in email 11 years 10 months ago #17663

  • octavian
  • octavian's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 783
  • Thank you received: 110
There's an easier method if you update to Rev43 (download it and install it again, we've added this little patch without changing the revision number) and use:
{field_name:text}
So if you have a dropdown named "Gender", with the following values:
m|Male
f|Female
using:
{Gender:text}
will return:
Male
while
{Gender:value}
will return:
m

This thread is now locked so that people can see the easier solution. If you have issues please submit a support ticket (if you are an active subscriber and wish to receive Customer Support) or open another post (if you want help from community users).
More information can be found in the docs
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 11 years 10 months ago by octavian.
The topic has been locked.
The following user(s) said Thank You: djaber2000, Woolpit
  • 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!