• 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: Combine three textbox values into one hidden field

Combine three textbox values into one hidden field 9 years 6 months ago #32674

Hi all,
Currently my users enter address Street name, Town and County. I am using RS Forms Pro. I wish to combine these three values separated by a comma into a hidden field. The purpose of this is so I can convert the address into a GMap LatLng value to store in a database.

I currently have the following code in the properties ->javascript/php:
<script type="text/javascript">
function calculateAddress()
{
document.getElementById('txtTotalAddress').value = document.getElementById('StreetName').value + ', ' + document.getElementById('NearestTown').value + ', ' + document.getElementById('OperationOperational').value;
return true; 
} 
</script>

I believe this should work but I don't know how to fire the event. Preferably when one of the address fields changes or are exited. Any ideas?
The administrator has disabled public write access.

Combine three textbox values into one hidden field 9 years 6 months ago #32676

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Edit your submit button and add something like this within the Additional Attributes area:
onclick="calculateAddress();"
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: maxmaggot123

Combine three textbox values into one hidden field 9 years 6 months ago #32681

Thanks for this.
I need to write this value to the database along with the other values. Is this the right approach to get the value written to the db. If I could put the value into a hidden field after the user clicks submit then I could write it to the db at the same time as the other values. I can't seem to get the value to write to a field using javascript.
The administrator has disabled public write access.

Combine three textbox values into one hidden field 9 years 6 months ago #32682

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Can you post a link to your form ?
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Combine three textbox values into one hidden field 9 years 6 months ago #32687

Hi,
It's running on localhost until next week when the client wants to make it live. I'll post the link then. Thanks so much for getting back to me.
The administrator has disabled public write access.

Combine three textbox values into one hidden field 9 years 6 months ago #32690

Just an idea. Does the onclick event occur before the SQL statement writes to the database? I could write the value to a hidden field with the onclick function and then write to all values to the database. Just a thought. Correct me if I'm wrong.
The administrator has disabled public write access.

Combine three textbox values into one hidden field 9 years 6 months ago #32695

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Javascript runs at a client side, not server side as SQL. To answer your question, yes, JS runs before SQL. This doesn't work for you because you most likely have JS errors like incorrect ID referrence or something similar.
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: maxmaggot123
  • 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!