Autoselect field from Title

  • builders
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 45
  • Thank you received: 0

builders created the topic: Autoselect field from Title

Hello

I have a selection list element of products at my form but i would like the form to auto select the product if the user is at a certain page of my site that is "product A" and the form is there so i would like the element of the form that says product to be auto filled at "product A".


Is that possible can you guide me?

Thanks
#233941
  • Posts: 2109
  • Karma: 72
  • Thank you received: 269

mihaela replied the topic: Autoselect field from Title

Hello,

Go to form's Advanced properties > More options > Scripts and in Initialization Script section set Type to Custom.

In the code area below put the following code:
function ff_formanme_init()
{

var urlPage= window.location.href ;
if( urlPage == "http://localhost/joomla/index.php/testredir") {
ff_getElementByName('selectlistname').selectedIndex= 2; }
else {
ff_getElementByName('selectlistname').selectedIndex= 0; }

} // ff_formanme_init
NOTE: In the code area above replace formname with the Name of your form.
Furthermore, replace selectlistname with the name of that select list element where option should be auto selected.

This is an example where THIRD option will be selected if page's URL is "http://localhost/joomla/index.php/testredir", because index is set to 2.

Otherwise, first option is auto selected.

Let me know whether you've managed to set this for your form and make it work as you wanted.

Regards,

Mihaela
#233968
  • builders
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 45
  • Thank you received: 0

builders replied the topic: Autoselect field from Title

Thanks that seems to work!!
#234012
  • Posts: 2109
  • Karma: 72
  • Thank you received: 269

mihaela replied the topic: Autoselect field from Title

Hello again,

I'm glad that it works. :)

Regards,

Mihaela
#234021
  • builders
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 45
  • Thank you received: 0

builders replied the topic: Autoselect field from Title

Hello again

i am trying to do something different now.

Is there a way to disable or hide a select list depending the url ?

Thanks
#234096
  • Posts: 5591
  • Karma: 118
  • Thank you received: 512

MarioPuco replied the topic: Autoselect field from Title

Hi,

Yes its possible :)

Here is an example on how-to do it. I'm sure you can connect the dots and pieces :

More Options > Form pieces > Before Form :
echo '
<script>
var urlFrom = document.referrer; // GET URL

switch(urlFrom) {

case "https://webaddress1.com":
jQuery(document).ready(function(){
   document.getElementById("#YOUR_SELECTLIST_ID").css("display","none");
 });
 break;

case "https://webaddress2.com":
jQuery(document).ready(function(){
   document.getElementById("#YOUR_SELECTLIST_ID").css("display","none");
 break;

}
</script>
';

Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#234097
Moderators: ForumSupporttomeperica
Time to create page: 0.216 seconds

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here