• 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: First form and question

First form and question 17 years 5 months ago #1357

I have completed a form for a charity web site I am working on. My review has not shown up yet, or I would have the \"trial version\" removed - sorry.

I will be purchasing a copy for other sites as well - works great.

Site URL:
http://www.kidsconnectionsc.org/index.php?option=com_forme&fid=3
(I will post this on the showcase when I complete it).

I have a question around the series of radio buttons for \"Organization Structure\" and \"if other, explain\".

Sequence of events I would like to happen:

The field \"If other, explain\" is hidden along with any reference to it.

User selects Organizational Structure type of \"Other\".

The field \"If other, explain\" shows for their information.

The question is - how do I do this? The other way I could accomplish what I want is to have the \"If other, explain\" field mandatory only if the radio button \"Other\" is selected.

Thank you for your help. And this is a work in progress... :)

Post edited by: amfonline, at: 2007/11/30 16:06<br><br>Post edited by: amfonline, at: 2007/11/30 18:34
The administrator has disabled public write access.

Re:First form and question 17 years 5 months ago #1366

  • alex
  • alex's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 443
  • Thank you received: 3
Ok amfoline, please do this:

1. edit the field OtherExplain and in the additional attributes type: style=display:none;
2. go to the form style tab, and at the end of the code, paste this code:
&lt;script language=\&quot;javascript\&quot;&gt;
	myradio = document.getElementById('OrganizationalStructure3');
	myradio.onclick = function(){
		document.getElementById('OtherExplain').style.display = 'inline';
	}
&lt;/script&gt;
I haven't tested the code, but should work. Basicly when you click on the radio button, it makes the otherExplain field visible.<br><br>Post edited by: alex, at: 2007/11/30 18:43
The administrator has disabled public write access.

Re:First form and question 17 years 5 months ago #1368

Thank you very much.

For anyone else using this example, (and this may not be the best way - I was guessing) -

I used the following code - Alex's is first, I stole it for each of the other radio buttons to turn it back off again if another option is clicked. If there are javascript experts that would like to correct me, please jump in.

<script language=\"javascript\">
myradio = document.getElementById('OrganizationalStructure3');
myradio.onclick = function(){
document.getElementById('OtherExplain').style.display = 'inline';
}
</script>
<script language=\"javascript\">
myradio = document.getElementById('OrganizationalStructure2');
myradio.onclick = function(){
document.getElementById('OtherExplain').style.display = 'none';
}
</script>
<script language=\"javascript\">
myradio = document.getElementById('OrganizationalStructure1');
myradio.onclick = function(){
document.getElementById('OtherExplain').style.display = 'none';
}
</script>
<script language=\"javascript\">
myradio = document.getElementById('OrganizationalStructure0');
myradio.onclick = function(){
document.getElementById('OtherExplain').style.display = 'none';
}
</script>

OrganizationalStructure0 - OrganizationalStructure2 were the other options the user could choose and none turrned the field back off. I think. :-)

Thanks again Alex!

Angela.
The administrator has disabled public write access.

Re:First form and question 17 years 2 weeks ago #2777

  • Spike00
  • Spike00's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hello,

I used same logic to achieve my goals, a bit more complex, involving a bit of html since on my onclik I have to turn on/of more fields.

Now it works, but if (as in my case) one or more of the 'hidden' (display: none) fields are mandatory, they still are processed so the form cannot be sent.

Any idea on ho to disable the check of 'hidden' (again, not usual form hidden fields, the ones with display none) fields?

Thanks
The administrator has disabled public write access.

Re:First form and question 17 years 2 weeks ago #2778

  • Spike00
  • Spike00's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Solved! :woohoo:

Need a small hack of forme.php (it could even be done in a next realease since if not using this feature it doesn't affect anything).

Well, in function processForm, just before the code that start the checking process, insert this code:
if (in_array($field-&gt;name, $disabled_fields)) {
  // No validation check thanks
}
else {

and of course close the else just after the end of the checking process, ie before these lines:
			}
			if(!empty($_SESSION['formmsg'])){
				mosRedirect(sefRelToAbs('index.php?option=com_forme&amp;Itemid='.$Itemid.'&amp;fid='.$fid));

In this way we have added a control that search for field ids in an array. If it finds the field id, it skips the checking process, otherwise it goes through the process as usual.

Now we just need to add our 'disabled' fields in the $disabled_fields array.

How? using the script called on form process area

just put there this kind of code:
 if($_POST['form']['your_radio'] == 'your_value') {
$disabled_fields = array('field1','field2','field3');
}

With this code, we're saying: if the user choosed 'your_value' of the radio 'your_radio', then we don't want to apply validation rules to the following fields: field1, field2, field3

where your_radio is the id of the radio field and your_value is one of the values of the radio

In my case I've 2 radio values, so I'll make another if statement for the second value of my radio.

End. :whistle:
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!