Hi,
In 'Designer mode' I have 'Text Box' named 'admin_list' with value 'tommy,pat'
In 'on load' action I have 'custom code' with content:
I just want to show value of my text box element (tommy,pat).
But this alert message is empty.
Could You tell me what I am doing wrong.
In 'Designer mode' I have 'Text Box' named 'admin_list' with value 'tommy,pat'
In 'on load' action I have 'custom code' with content:
<?php
$adm=$form->data['admin_list'];
echo "<script type='text/javascript'>alert('$adm');</script>";
?>
I just want to show value of my text box element (tommy,pat).
But this alert message is empty.
Could You tell me what I am doing wrong.
Hi xquest,
I think that the problem here is that the value isn't set at the time the Custom Code action is run.
You can do this using a Load JavaScript action instead
Bob
I think that the problem here is that the value isn't set at the time the Custom Code action is run.
You can do this using a Load JavaScript action instead
jQuery(document).ready(function(jQ) {
var admin_list;
admin_list = jQ('#admin_list').val();
alert(admin_list);
});
Please make sure that the Text Box has the ID set to admin_list.
Bob
Thank You for your answer.
Now I can read value of my text box:
jQuery(document).ready(function(jQ) {
var admin_list;
admin_list = jQ('#admin_list').val();
alert(admin_list);
});
but realy I do not want to alert it, but use this variable in php.
I do not know how to transfer var from javascript(my text box value) to php tags, where i can do some more action. Is it possible??
Now I can read value of my text box:
jQuery(document).ready(function(jQ) {
var admin_list;
admin_list = jQ('#admin_list').val();
alert(admin_list);
});
but realy I do not want to alert it, but use this variable in php.
I do not know how to transfer var from javascript(my text box value) to php tags, where i can do some more action. Is it possible??
Hi.
I just want to read value from 'text box' , and later I want to operate this value by means of php code.
So I want to do 2 things:
1. read value from text box ('load javascript' because custom code doesn't work in this case)
2. operate with this value with php code.
I just want to read value from 'text box' , and later I want to operate this value by means of php code.
So I want to do 2 things:
1. read value from text box ('load javascript' because custom code doesn't work in this case)
2. operate with this value with php code.
Hi xquest,
I'm sorry but that still makes no sense to me. Please spell out where you want to do this?
If you want to do this after the form submits then the value is in the $form->data[''] array - you can see it by adding a Debugger action to the form On Submit event.
Bob
I'm sorry but that still makes no sense to me. Please spell out where you want to do this?
If you want to do this after the form submits then the value is in the $form->data[''] array - you can see it by adding a Debugger action to the form On Submit event.
Bob
I want to read some value from 'text box value' and I want to edit this value with php function.
I want to do it in "form on load" event, before submitting, before user enter their own data.
And it would be great do it in custom code, but
gives me empty value.
I want to do it in "form on load" event, before submitting, before user enter their own data.
And it would be great do it in custom code, but
<?php
$adm=$form->data['admin_list'];
?>
gives me empty value.
Hi xquest,
But there is no data in a form element when the form loads unless you put it there?
I still have no idea what you are trying to do here :-(
Bob
But there is no data in a form element when the form loads unless you put it there?
I still have no idea what you are trying to do here :-(
Bob
oh, now I see.
So even In 'Designer mode' I have 'Text Box' with value 'some_text', this value is not transfered into my form (onload) yes ??
So even In 'Designer mode' I have 'Text Box' with value 'some_text', this value is not transfered into my form (onload) yes ??
hmm, but visually I see this value.
So I want to ask what is difference beetween 'custom code' who can not read this value and 'load javascript' who can read this value.
Both this action are used in "on load form"
So I want to ask what is difference beetween 'custom code' who can not read this value and 'load javascript' who can read this value.
Both this action are used in "on load form"
Hi xquest,
So even In 'Designer mode' I have 'Text Box' with value 'some_text', this value is not transfered into my form (onload) yes ??
Yes it is - as you have seen.
So I want to ask what is difference beetween 'custom code' who can not read this value and 'load javascript' who can read this value.
Custom code is PHP run before the Form HTML is created. Usually ti is used to prepare data for use in the form; for example to run a custom database query. The Load JavaScript action adds JavaScript to the Form HTML that can be run in the browser after the form is displayed.
I still have no idea what you are trying to do :-(
Bob
So even In 'Designer mode' I have 'Text Box' with value 'some_text', this value is not transfered into my form (onload) yes ??
Yes it is - as you have seen.
So I want to ask what is difference beetween 'custom code' who can not read this value and 'load javascript' who can read this value.
Custom code is PHP run before the Form HTML is created. Usually ti is used to prepare data for use in the form; for example to run a custom database query. The Load JavaScript action adds JavaScript to the Form HTML that can be run in the browser after the form is displayed.
I still have no idea what you are trying to do :-(
Bob
Ok, excuse me , I will try to show what am I doing😉
My target is to write id of special users (some admins, some registered) in hidden field value.
[attachment=0]1.JPG[/attachment]
Now before form appear I want to check if my user is one of them (special users). So in this place I want to read value of hidden field or text box, and i want to trim this text via php.
If user isn't "vip" some container will be hidden, other way some will be visibled.
My target is to write id of special users (some admins, some registered) in hidden field value.
[attachment=0]1.JPG[/attachment]
Now before form appear I want to check if my user is one of them (special users). So in this place I want to read value of hidden field or text box, and i want to trim this text via php.
If user isn't "vip" some container will be hidden, other way some will be visibled.
Hi xquest,
In Joomla! 3 you can create a new User Group for VIP users and add them to it.
You can get the list of user group with this PHP in a Custom Code action
Then $form->data['vip'] will be true if the user is a VIP, false otherwise.
You can use this to set CSS or PHP to hide or display elements. For example use a Container of Type Custom and put this in the Start box
Bob
In Joomla! 3 you can create a new User Group for VIP users and add them to it.
You can get the list of user group with this PHP in a Custom Code action
<?php
$user = JFactory::getUser();
$groups = $user->getAuthorisedGroups();
$form->data['vip'] = (in_array('99', $groups) ); // replace 99 with the VIP group ID.
?>
Then $form->data['vip'] will be true if the user is a VIP, false otherwise.
You can use this to set CSS or PHP to hide or display elements. For example use a Container of Type Custom and put this in the Start box
<?php
if ( $form->data['vip'] ) {
$display = 'block';
} else {
$display = 'none';
}
echo "<div style='display: {$display};' >";
?>
and then put </div> in the End box.
Bob
This topic is locked and no more replies can be posted.