• 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: Trying to generate a value in a hidden field

Trying to generate a value in a hidden field 11 years 2 months ago #26643

  • info9336
  • info9336's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hi, I'm new to PHP and Javascript but I'm trying to setup a form which asks a person for it's name. The value that is added to that field will have to be processed so the input is put to lowercase and all spaces are replaced with '-'. I've experimented with jQuery and got the following:
var jku= $('#naam').val().toLowerCase();
jku = jku.replace(/\ /g, '-');
$('#slug').val(jku);
The last string works fine in a empty HTML document, it displays the value of the input-field with id="name" and displays the name in lowercase with all spaces replaced. When I put this in the script called on form process like this:
echo("");
?>
 
<script type-="text/javascript">
	var jku= $('#naam').val().toLowerCase();
	jku = jku.replace(/\ /g, '-');
	$('#slug').val(jku);
       <? php $_POST['no-title']['slug'] ?> = jku 
</script>
 
<? php echo("");
It doesn't get called in the hiddenfield with id="slug".

I've read in the documentation about the $_POST command, but don't know how to implement. Could anybody please help!

Thanks in advance!

Kind regards,
Job Kuipers
The administrator has disabled public write access.

Trying to generate a value in a hidden field 11 years 2 months ago #26649

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

RSForm!Pro has different areas for PHP, JavaScript, CSS, HTML. JavaScript is added by going to backend > Components > RSForm!Pro > Manage Forms > your form > Properties > CSS and JavaScript > JavaScript area.

Instead of using JavaScript, within "Scripts called on form process" area, you could try lowering and changing the spaces into dashed through PHP directly and afterwards you can assign the value to the hidden field with something like:
if(empty($invalid)){
$lower = strtolower($_POST['form']['naam']);
$final = str_replace(' ','-',$lower);
 
$_POST['form']['slug'] = $final;
}

More information on the RSForm!Pro PHP Scripts areas can be found here:

www.rsjoomla.com/support/documentation/v...602-php-scripts.html
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.
The following user(s) said Thank You: info9336

Trying to generate a value in a hidden field 11 years 2 months ago #26671

  • info9336
  • info9336's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hi Adrian,
Thanks for your reply. I've tried implementing it, but it still doesn't get executed on Form process. I don't know PHP unfortunately, could you please explain the if statement in the beginning. I would like to fill the hidden field (called 'slug') always on form submission, not only when something is empty or invalid (or does the if statement something else?
Thanks in advance for your help!

Kind regards,
Job Kuipers
The administrator has disabled public write access.

Trying to generate a value in a hidden field 11 years 2 months ago #26686

  • info9336
  • info9336's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
I've managed to get it to work using the Javascript-field in RS-Form:


$( document ).ready(function() {
		jQuery("#naam").blur(function() {
			var slug = jQuery('#naam').val().toLowerCase();
			slug = slug.replace(/\ /g, '-');
			jQuery('input#slug').attr('value', slug);
		});
});

Thanks for your cooperation!
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!