简体   繁体   中英

Insert textbox value based on logged in user?

Good day

I would like to do the following. I am using Joomla and RSForm Pro component.

I'd like to fill a textbox with a certain value based on who is logged in.

Something like this:

<?php 
$user = JFactory::getUser();
if($user->id==42) { ?>
<script type="text/javascript">
$(document).ready(function(){
$("#Email1").value = "testmail@test.com";
});
</script>
}
?>

However, in RSForm pro there is 3 different PHP "areas". They are:

  1. Script called on form display (HTML code of the form)

  2. Script called on form process (POST Data)

  3. Script called after form has been processed (Thank you Message)

They also mention to not include the "php" opening and closing tags, so I don't understand how I'm supposed to use the php tags when I want other scripts such as Javascript involved.

Basically, it must just set the value for 5 fields, textboxes #Email1 to #Email5, depending on the user which is logged in. When the form is submitted, the users will still receive the values.

RSForm!Pro has a hidden feature where you can assign dynamic values to textboxes. Essentially, you can add any PHP code to the field's default value and it will get executed, as long as it has the string inside it, and as long it doesn't have the PHP closing and ending tags. Check this comprehensive post on how to assign dynamic values to fields in RSForm!Pro.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM