fbpx
Welcome, Guest
Username: Password: Remember me

TOPIC: (SOLVED) Preloaded values in form elements

Preloaded values in form elements 1 year 2 months ago #28605

  • Gurevich
  • Gurevich's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Karma: 0
Hello,
Is there any way to preload value into form element?
For example, when loading a form, the Email field will show current logged-on user email (assume I have this value in $usermail variable).
Thanks!
Last Edit: 1 year 2 months ago by Gurevich. Reason: Clarification
The administrator has disabled public write access.

Preloaded values in form elements 1 year 2 months ago #28607

  • nishtha
  • nishtha's Avatar
  • Offline
  • Moderator
  • Posts: 2436
  • Thank you received: 218
  • Karma: 36
Hi,

Currently this is not possible, but it seems to be a good suggestion I shall forward it to the technical team and let you know what they decide about it.

I'll update you here once there is any conclusion to this.

Thanks,
Nishtha
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.

To know more about products check out the their documentation.
The administrator has disabled public write access.

Preloaded values in form elements 1 year 2 months ago #28621

  • Gurevich
  • Gurevich's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Karma: 0
Thank you!
The administrator has disabled public write access.

Preloaded values in form elements 1 year 2 months ago #28636

  • watched.live
  • watched.live's Avatar
  • Offline
  • Junior Member
  • Posts: 23
  • Thank you received: 4
  • Karma: 2
You could do it using the HTML form element to use jquery (or some other embedded script) to modify the value of the field. As long as you have the $usermail displayed somewhere else on the page, you can pull the value into the script and then set the field value. If it actually is a variable already available to you in javascript, even easier.

Assuming that the Form Element name is "emailfield", the bare minimum script is:
<script language="javascript">
    $JDB('input[id$=-emailfield]').val('name\@example.test');
</script>
(note that the \ before @ is required, otherwise joomla tries to obfuscate the address, and everything breaks)

Note though, this very basic version will still have the field blanked out on submit. If you want it re-populated after the blanking, that would need some other hooks.

All in all, the most complete method would be having the feature added (as nishtha is forwarding the request).
The administrator has disabled public write access.
The following user(s) said Thank You: Gurevich

Preloaded values in form elements 1 year 2 months ago #28654

  • Gurevich
  • Gurevich's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Karma: 0
Hi @watched.live,

Many thanks for your input! I managed to add default value to the form field by using Raw HTML component (after it was imported to Java variable):
<script language="javascript">
    document.getElementsByName("emailfield")[0].value = myEmail;
</script>

Indeed, using native feature (as it will be hopefully added) should significantly simplify this task.

Thumb up! :)
The administrator has disabled public write access.

Preloaded values in form elements 1 year 2 months ago #28696

  • nishtha
  • nishtha's Avatar
  • Offline
  • Moderator
  • Posts: 2436
  • Thank you received: 218
  • Karma: 36
Hi,

Great! if that worked for you, problem look solved then.
In the meanwhile we'll see what can be done here with JD Builder

Thanks,
Nishtha
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.

To know more about products check out the their documentation.
The administrator has disabled public write access.
Moderators: chandandeep
Time to create page: 0.437 seconds
Cron Job Starts