• 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: Reset <select> HTML Attributes

Reset <select> HTML Attributes 9 years 7 months ago #32607

Hello RS,


I have customized the form to change colors after the user completes an input field. All of the customizations worked great with the exception of the <select> elements which needed the code below.
onchange="this.style.color = this.options[this.selectedIndex].style.color;"

This works; however, when the 'reset' button is pressed, all of the form values are reset but the HTML attributes of the <select> elements are not. What can I use to target the select elements as well?

Website
<select> elements arefound under the 'Valve Information' section.
The administrator has disabled public write access.

Reset <select> HTML Attributes 9 years 7 months ago #32621

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

You can try these steps:

- use a small PHP script (backend > Components > RSForm!Pro > Manage Forms > your form > Properties > PHP Scripts > Scripts Called on Form Display) to place an onclick triggering a function on the reset button:
$formLayout = str_replace('type="reset"','type="reset" onclick="myFunction"',$formLayout);

- use a JavaScript function (while editing a form > Properties > CSS and JavaScript > JavaScript), including the <script> tags:
<script type="text/javascript">
function myFunction{
	var selectLen = document.getElementsByTagName('select').length;
	for(var i=0; i < selectLen; i++){
		document.getElementsByTagName('select')[i].style.color = '';
	}
}
</script>
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.

Reset <select> HTML Attributes 9 years 7 months ago #32623

I'm afraid this did not work. Any other suggestions?
The administrator has disabled public write access.

Reset <select> HTML Attributes 9 years 7 months ago #32628

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

Please try replacing (found once in each script PHP/JavaScript):

myFunction

With your desired function name (example):

resetColor()
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.

Reset <select> HTML Attributes 9 years 6 months ago #32652

Sorry, this didn't work either.
The administrator has disabled public write access.

Reset <select> HTML Attributes 9 years 6 months ago #32663

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

It appears the resetColor() function is missing its brackets from the PHP script. This should be:
$formLayout = str_replace('type="reset"','type="reset" onclick="resetColor();"',$formLayout);
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: JxnGraphix

Reset <select> HTML Attributes 9 years 6 months ago #32671

Perfect, thank you!
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!