I need a little help

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

I need a little help

Post by dgasparin » 2020-03-28 13:18

Hello to everyone,
I'm very new about PHP and JavaScript.
I need your help about a simple question, simple for you not for me.
The target is in the same table I have to copy a field in another one using a button.
I wrote this :
$j(function() {
$j(
'<div class="btn-group-vertical btn-group-lg vspacer-lg" style="width: 100%;">' +
'<button type="button" class="btn btn-primary btn-lg">' +
'<i class="glyphicon glyphicon-list-alt"></i> Check Heart Rate' +
'</button>' +
'</div>'
).appendTo('.detail_view .btn-toolbar');
$j("reqhr").clone().appendTo("command");
If I wrote rightly, now I need a string to execute the last string when I click the button
Could you please help me?
Thank you so much

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: I need a little help

Post by pbottcher » 2020-03-28 17:36

Hi,

as I cannot say if the statement $j("reqhr").clone().appendTo("command"); will work, ( I would guess it does not as your selectors seem odd)
and I do not have the information about your fields (and fieldtype) I can only provide parital information.
You could try something like the below for your button. Keep in mind, that every time the user will click the butten the copy function will be called.

Code: Select all

function copy() {
	<!-- put here the code you need to copy your data -->
}
$j(function() {

$j(
'<div class="btn-group-vertical btn-group-lg vspacer-lg" style="width: 100%;">' +
'<button id="bc" onclick="copy()" type="button" class="btn btn-primary btn-lg">' +
'<i class="glyphicon glyphicon-list-alt"></i> Check Heart Rate' +
'</button>' +
'</div>'
).appendTo('.detail_view .btn-toolbar');
});
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: I need a little help

Post by dgasparin » 2020-03-29 08:04

Thank you so much for your help.
I really appreciate.
I will test now
Thank you

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: I need a little help

Post by dgasparin » 2020-03-29 08:37

I beg your pardon disturbing you now.
Just to explain better the situation, I need to copy the string inside the reqhr to the string called command.
How can I do this?
Thank you so much for your big patience, availability and kindness
Best regards
Davide
Best regards

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: I need a little help

Post by pbottcher » 2020-03-29 10:48

Hi,

what fields are reqhr and command? input fields? maybe you can post a screenshot.

at a first shot you may try $j('#command').val($j('#reqhr').val()) to copy.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: I need a little help

Post by dgasparin » 2020-03-29 12:03

Thank you for your answer.
I put here the screenshoot of both.
Basically reqhr is an autofill field. It is automatically made when I put values in other fields.
command in a text filed where I have to copy reqhr
Thank you so much for your help
Davide
Attachments
reqhr.PNG
reqhr.PNG (1.85 KiB) Viewed 2665 times
command.PNG
command.PNG (915 Bytes) Viewed 2665 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: I need a little help

Post by pbottcher » 2020-03-29 12:51

ok, thanks, so in that case you can try

$j('#command').val($j('#reqhr').text().trim());
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: I need a little help

Post by dgasparin » 2020-03-29 12:59

Dear pböttcher, you are my hero.
Thank you so much
It is working
Thank you

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: I need a little help

Post by dgasparin » 2020-03-31 09:02

Good morning
I apologise disturbing you today.
I need a help yet about this.
The target is the same, to copy a string inside a mysql field.
Using your advice I sorted out the problem but I faced other new:
  • I can hide the fields on the webpage because if they are not visible, rightly , the function doesn't works and I can't leave the visible.
So to sort out the problem I changed way using a direct access to the DB. To do this I wrote two different files:
  • .js file to make the button and to call the .php file
  • .php file to make the string using the db data
This is the php file and I have a problem. The program works rightly but inside the wid the are a lot of data and I need to read only one. The wid connected to the customer.
Could you helo me to add the right filter to select the right wid please?
Thank you so much
Davide
<?php
$code=",073#";
$code1="IXL,";
$row= ["wid"];

$servername = "localhost";
$database = "c1ms";
$username = "c1us";
$password = "test";

// Create connection

$conn = mysqli_connect($servername, $username, $password, $database);
$sql = "SELECT wid FROM patients";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $codeheart."".$row["wid"]."".$code. "<br>";
}
}
?>

Post Reply