Get clicked href variable from one page to another - javascript

Greeting everyone,
Currently i'm making a webpage that has the following functions:
When the administrator opens the page, admin will be seeing a form filled with these information from a database:
What this page does is that it shows how many video's each user has in the database and when the admin clicks on the desired user ID, a new page should open with the video's of that specific user ID. The " DONE" button is to return to the main page when the admin is done deleting video's.
Now, what I have done is that I've assigned an href link to the userID values that is being fetched from Database. The problem is that, I have no clue how to pass the selected value/string to the next page with href. I've tried with Session, but ended up getting the last variable processed in the WHILE loop instead of getting the clicked UserID. Below follows my php code of what I've done. Can anyone give me some tips on how to pass the clicked userID from one page to another with href, or is there another way to do this?
code= click here
ps: As everyone can see, my php coding needs some serious improvement. But i'm still trying to improve by doing these types of exercises.
<?php
include_once ("includes/db_connection.php");
$sql = "SELECT Users_UserID, count(Users_UserID) AS total FROM video GROUP BY Users_UserID";
$sql2="SELECT UserID, FirstName, LastName FROM users";
$result = $connection->query($sql);
$result2 = $connection->query($sql2);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="deleteSingleVideo" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete user video</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>First Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Last Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>User ID</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Amount of videos</strong></td>
</tr>
<?php
session_start();
if ($result->num_rows > 0) {
while (($row=$result->fetch_assoc())&& ($row2=$result2->fetch_assoc()) ) {
?>
<tr>
<td align="center" bgcolor="#FFFFFF"></td>
<td bgcolor="#FFFFFF"><center><?php echo $row2['FirstName']; ?></center></td>
<td bgcolor="#FFFFFF"><?php echo $row2['LastName']; ?></td>
<td bgcolor="#FFFFFF"><center><a href="DeleteVideo.php" target="_blank"><?php echo $row['Users_UserID'];
$_SESSION['id']=$row['id'] ?></center></td>
<td bgcolor="#FFFFFF"><center><?php echo $row['total'];?></a></center></td>
</tr>
<?php
}
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="Done" type="submit" id="Done" value="Done" </td>
</tr>
<?php
$connection->close();
if(isset($_POST['Done'])){
header( "Location: Home.php" );
}
?>
</table>
</form>
</td>
</tr>
</table>
<?php
?>

this is not a good use of session
use get method to send such data :
append the id to href url --->href="<?php echo "DeleteVideo.php?id="$row['id'] ?>";
get data in the next page by accessing global variable ---> $_GET['id']

..
In the DeleteVideo.php your variable is $_GET['id']

use this code
and that id value get in xyz.php
$value=$_request['id'];
or
$value=$_Get['id'];

Related

live filter on a database's query

I'm creating a web app where users can easy access to information in a database.
I already wrote the code in PHP and MYSQL where the user can enter for example the dna Code of a patient and all data of that patient is displayed in a table.
What I would like to do now is filter the data in the table using live filters??
I already looked for a JavaScript code, but it doesn't work since the site has dynamic tables that changes according to what the user want to look up.
The thing I would like to create is filters to apply to the table I already have, in which every column has a dropdown that help the user filter the data in the table.
I looked for jQuery, datatable and bootstrap applications but I can't figure it out.
Thank you so much
I'll attach here my code because I already tried to insert some line of codes with jquery and data table but nothing changes.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<title>FILTRARE PER GENE</title>
</head>
<body>
<div id="holder">
<h1><?php echo "FILTRO PER GENE DELLE VARIANTI";?></h1></div>
<hr />
<br>
<div id="sidebar" style="width:50%">
NUOVA RICERCA
&nbsp |
DATI UTENTE
&nbsp |
HOME
<P> </P>
</div>
<div>
<BR>
<form action="variante.php" method="POST">
CODICE DNA <input type="text" name="dna" val="">
GENE <select name="gene">
<option></option>
<option>CFH</option>
<option>CD46</option>
<option>CFI</option>
<option>CFB</option>
<option>C3</option>
<option>ADAMTS13</option>
<option>THBD</option>
<option>DGKE</option>
<input type='submit' name='vai' value'Invia'>
</form><BR /><BR />
<?php
$conn= mysql_connect("start", "db", "password");
if (!$conn)
{
die("Connessione non riuscita <br>" . mysql_error());
//}else{
//echo "Connessione al database stabilita con successo<br><br>";
}
mysql_select_db("variant_db", $conn);
if(isset($_POST["vai"])){
$gene=$_POST["gene"];
}
echo "Verranno visualizzati i risultati per il gene '<b>$gene</b>' selezionato.<br><br>";
$sql_gene= "SELECT V.dnaCode, V.Chr, V.Start, V.End, V.Alt, V.Ref, V.zygosity, A.gene, A.Func, A.GeneContext, A.Dist FROM variante as V JOIN annotazioni as A ON V.Start = A.Start AND V.Alt=A.Alt AND V.Ref=A.Ref WHERE A.gene='" .$gene. "'";
$result_gene = mysql_query($sql_gene, $conn) or die(mysql_error());;
$record_gene = mysql_fetch_array($result_gene);
if($record_gene==false)
{
echo "<br>La ricerca non ha prodotto alcun risultato con il gene selezionato!<br>";
echo"Il paziente non presenta varianti sul gene '<b>$gene</b>'.<br>";
}else
{
$index=1;?>
<table id="tab_annvar" width="100%">
<thead>
<tr>
<td width="9%"><b>RISULTATO</b></td>
<td width="9%"><b>dnaCode</b></td>
<td width="9%"><b>Chr</b></td>
<td width="9%"><b>Start</b></td>
<td width="9%"><b>End</b></td>
<td width="5%"><b>Alt</b></td>
<td width="5%"><b>Ref</b></td>
<td width="9%"><b>Zigosity</b></td>
<td width="9%"><b>Gene</b></td>
<td width="9%"><b>Func</b></td>
<td width="9%"><b>Gene Context</b></td>
<td width="9%"><b>Dist</b></td>
</tr>
</thead>
<?php while ($record_gene = mysql_fetch_array($result_gene))
{?>
<tbody>
<tr>
<b><td width="9%"><?php echo "#$index";?></td></b>
<td width="9%"><?php echo $record_gene["dnaCode"];?></td>
<td width="9%"><?php echo $record_gene["Chr"];?></td>
<td width="9%"><?php echo $record_gene["Start"];?></td>
<td width="9%"><?php echo $record_gene["End"];?></td>
<td width="5%"><?php echo $record_gene["Alt"];?></td>
<td width="5%"><?php echo $record_gene["Ref"];?></td>
<td width="9%"><?php echo $record_gene["zygosity"];?></td>
<td width="9%"><?php echo $record_gene["gene"];?></td>
<td width="9%"><?php echo $record_gene["Func"];?></td>
<td width="9%"><?php echo $record_gene["GeneContext"];?></td>
<td width="9%"><?php echo $record_gene["Dist"];?></td>
</tr>
</tbody>
<?php
++$index;
}
}?>
</table>
</div>
</body>
</html>
You are on the right way for "live filters". You definetly need some JavaScript. Which one you chose is up to you.
For instance, you can use jQuery and AJAX for requesting your data from the backend as:
$.ajax({
url: "interface.php?client=1234",
type: 'GET',
success: function(html){
//update your UI here
}
});
Be aware that you probably will have a lot of traffic, depending up on your amount of data and/or user. Therefore, you could think about some kind of caching.
You have to retrieve your data async and you can use the following plugin to get what you need
https://www.jqueryscript.net/table/Simple-jQuery-Dropdown-Table-Filter-Plugin-ddtf-js.html

MPGS integration 3DSecure PHP

I've downloaded the Direct Payment Sample_REST-JSON_PHP.zip . I successfully integrated with my merchant info, but when doing the pay operation in x_pay_simple.html I get the following error
{
"error": {
"cause": "INVALID_REQUEST",
"explanation": "Missing parameter. value: null - reason: A 3DS Authentication ID value or 3DS Authentication Details is required for the transaction source used for this transaction",
"field": "3DSecure",
"validationType": "MISSING"
},
"result": "ERROR"
}
I read the docs and I understood that 3DSecure is generated from the gateway, I think add payment & 3Dsecure are done in 1 use case.
how can I add 3DSecure to my implementation ?
Here's the HTML :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<link rel="stylesheet" type="text/css" href="./assets/paymentstyle.css" />
<head>
<title>API Example Code</title>
<meta http-equiv="Content-Type" content="text/html, charset=iso-8859-1">
</head>
<body>
<h1>PHP Example - REST (JSON)</h1>
<h3>Simple Pay Operation</h3>
<p>Return to the Home Page</p>
<form action="./process.php" method="post">
<table width="60%" align="center" cellpadding="5" border="0">
<!-- Credit Card Fields -->
<tr class="title">
<td colspan="2" height="25"><P><strong>URL Fields</strong></P></td>
</tr>
<tr>
<td colspan="2" height="25"><P class="desc">Order and Transaction IDs are required and used to calculate the URL along with the version and merchant ID. In your integration, you would calculate these fields within your code (process.php based on this example) and not expose these to the card holder on this page, or pass them as hidden fields.</P></td>
</tr>
<tr class="shade">
<td align="right" width="50%"><strong>version </strong></td>
<td width="50%"><input type="text" readonly="readonly" name="version" value="34" size="8" maxlength="80" /></td>
</tr>
<tr>
<td align="right" width="50%"><strong>order.id</strong></td>
<td><input type="text" name="orderId" value="" size="20" maxlength="60"/></td>
</tr>
<tr class="shade">
<td align="right" width="50%"><strong>transaction.id</strong></td>
<td><input type="text" name="transactionId" value="" size="20" maxlength="60"/></td>
</tr>
<tr><td colspan="2"></td></tr>
<tr class="title">
<td colspan="2" height="25"><P><strong> Transaction Fields</strong></P></td>
</tr>
<tr>
<td align="right" width="50%"><strong>method </strong></td>
<td width="50%"><input type="text" readonly="readonly" name="method" value="PUT" size="20" maxlength="80"/> ** See Note 1 Below</td>
</tr>
<tr class="shade">
<td align="right" width="50%"><strong>apiOperation </strong></td>
<td width="50%"><input type="text" readonly="readonly" name="apiOperation" value="PAY" size="20" maxlength="80"/></td>
</tr>
<tr>
<td align="right"><strong>sourceOfFunds.type </strong></td>
<td><input type="text" name="sourceOfFunds[type]" value="CARD" size="19" maxlength="80"/></td>
</tr>
<tr class="shade">
<td align="right"><strong>sourceOfFunds.provided.card.number </strong></td>
<td><input type="text" name="sourceOfFunds[provided][card][number]" value="" size="19" maxlength="80"/></td>
</tr>
<tr>
<td align="right"><strong>sourceOfFunds.provided.card.expiry.month </strong></td>
<td><input type="text" name="sourceOfFunds[provided][card][expiry][month]" value="" size="1" maxlength="2"/></td>
</tr>
<tr class="shade">
<td align="right"><strong>sourceOfFunds.provided.card.expiry.year </strong></td>
<td><input type="text" name="sourceOfFunds[provided][card][expiry][year]" value="" size="1" maxlength="2"/></td>
</tr>
<tr>
<td align="right"><strong>sourceOfFunds.provided.card.securityCode </strong></td>
<td><input type="text" name="sourceOfFunds[provided][card][securityCode]" value="" size="8" maxlength="4"/></td>
</tr>
<tr class="shade">
<td align="right"><strong>order.amount </strong></td>
<td><input type="text" name="order[amount]" value="" size="8" maxlength="13"/></td>
</tr>
<tr>
<td align="right"><strong>order.currency </strong></td>
<td><input type="text" name="order[currency]" value="SAR" size="8" maxlength="3"/></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" name="submit" value="Process Payment"/></center></td>
</tr>
<tr><td colspan="2"></td></tr>
<tr>
<td colspan="2" height="25"><P class="desc"><strong>Note 1:</strong> This field is used by this example to set the HTTP Method for sending the transaction. In your integration, you should determine the HTTP Method in your code (process.php based on this example) and never display it to the card holder or pass it as a hidden field.</P></td>
</tr>
</table>
</form>
<br/><br/>
</body>
process.php
<?php
/* Main controller page
1. Create 1 MerchantConfiguration object for each merchant ID
2. Create 1 Parser object
3. Call Parser object FormRequest method to form the request that will be sent to the payment server
4. Parse the formed reqest to SendTransaction method to attempt to send the transaction to the payment server
5. Store the received transaction response in a variable
6. Include receipt page which will output the response HTML and parse the server response
*/
include "configuration.php";
include "connection.php";
// This is used to set the HTTP operation for sending the transaction
// In your integration, you should never pass this in, but set the value here based on your requirements
if (array_key_exists("method", $_POST))
$method = $_POST["method"];
// The following section allows the example code to setup the custom/changing components to the URI
// In your integration, you should never pass these in, but set the values here based on your requirements
$customUri = "";
if (array_key_exists("orderId", $_POST))
$customUri .= "/order/" . $_POST["orderId"];
if (array_key_exists("transactionId", $_POST))
$customUri .= "/transaction/" . $_POST["transactionId"];
// Add any HTML/$_POST field names that you want to unset to this array
// If you have any other fields in the HTTP POST, you need to process them here and remove from $_POST
// After this, $_POST should only contain fields that are being sent as part of the transaction
$unsetNames = array("orderId", "transactionId", "submit", "method");
// loop through each field in the unsetNames array
// unset the field if the key exists
foreach ($unsetNames as $fieldName) {
if (array_key_exists($fieldName, $_POST))
unset($_POST[$fieldName]);
}
// Creates the Merchant Object from config. If you are using multiple merchant ID's,
// you can pass in another configArray each time, instead of using the one from configuration.php
$merchantObj = new Merchant($configArray);
// The Parser object is used to process the response from the gateway and handle the connections
$parserObj = new Parser($merchantObj);
// In your integration, you should never pass this in, but store the value in configuration
// If you wish to use multiple versions, you can set the version as is being done below
if (array_key_exists("version", $_POST)) {
$merchantObj->SetVersion($_POST["version"]);
unset($_POST["version"]);
}
// form transaction request
$request = $parserObj->ParseRequest($_POST);
// if no post received from HTML page (parseRequest returns "" upon receiving an empty $_POST)
if ($request == "")
die();
// print the request pre-send to server if in debug mode
// this is used for debugging only. This would not be used in your integration, as DEBUG should be set to FALSE
if ($merchantObj->GetDebug())
echo $request . "<br/><br/>";
// forms the requestUrl and assigns it to the merchantObj gatewayUrl member
// returns what was assigned to the gatewayUrl member for echoing if in debug mode
$requestUrl = $parserObj->FormRequestUrl($merchantObj, $customUri);
// this is used for debugging only. This would not be used in your integration, as DEBUG should be set to FALSE
if ($merchantObj->GetDebug())
echo $requestUrl . "<br/><br/>";
// attempt sending of transaction
// $response is used in receipt page, do not change variable name
$response = $parserObj->SendTransaction($merchantObj, $request, $method);
// print response received from server if in debug mode
// this is used for debugging only. This would not be used in your integration, as DEBUG should be set to FALSE
if ($merchantObj->GetDebug()) {
// replace the newline chars with html newlines
$response = str_replace("\n", "<br/>", $response);
echo $response . "<br/><br/>";
die();
}
// the receipt page is included and displayed here.
// in your integration, you would most likely also want process the transaction response, and make appropriate updates
// you can see how to parse and retrieve the results and other fields in the transaction at the top of receipt.php
include "receipt.php";
?>
receipt.php
<?php
//Rima - start
include "process.php";
//Rima - end
$errorMessage = "";
$errorCode = "";
$gatewayCode = "";
$result = "";
$tmpArray = array();
// [Snippet] howToDecodeResponse - start
// $response is defined in process.php as the server response
$responseArray = json_decode($response, TRUE);
// [Snippet] howToDecodeResponse - end
// either a HTML error was received
// or response is a curl error
if ($responseArray == NULL) {
print("JSON decode failed. Please review server response (enable debug in config.php).");
die();
}
// [Snippet] howToParseResponse - start
if (array_key_exists("result", $responseArray))
$result = $responseArray["result"];
// [Snippet] howToParseResponse - end
// Form error string if error is triggered
if ($result == "FAIL") {
if (array_key_exists("reason", $responseArray)) {
$tmpArray = $responseArray["reason"];
if (array_key_exists("explanation", $tmpArray)) {
$errorMessage = rawurldecode($tmpArray["explanation"]);
}
else if (array_key_exists("supportCode", $tmpArray)) {
$errorMessage = rawurldecode($tmpArray["supportCode"]);
}
else {
$errorMessage = "Reason unspecified.";
}
if (array_key_exists("code", $tmpArray)) {
$errorCode = "Error (" . $tmpArray["code"] . ")";
}
else {
$errorCode = "Error (UNSPECIFIED)";
}
}
}
else {
if (array_key_exists("response", $responseArray)) {
$tmpArray = $responseArray["response"];
if (array_key_exists("gatewayCode", $tmpArray)){
$gatewayCode = rawurldecode($tmpArray["gatewayCode"]);
}
}
else
$gatewayCode = "Response not received.";
}
}
?>
<!-- The following is a simple HTML page to display the response to the transaction.
This should never be used in your integration -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<link rel="stylesheet" type="text/css" href="assets/paymentstyle.css" />
<head>
<title>API Example Code</title>
<meta http-equiv="Content-Type" content="text/html, charset=iso-8859-1">
</head>
<body>
<br/>
<center><h1>PHP Example - REST (JSON)</h1></center>
<center><h3>Receipt Page</h3></center><br/><br/>
<table width="60%" align="center" cellpadding="5" border="0">
<?php
// echo HTML displaying Error headers if error is found
if ($errorCode != "" || $errorMessage != "") {
?>
<tr class="title">
<td colspan="2" height="25"><P><strong> Error Response</strong></P></td>
</tr>
<tr>
<td align="right" width="50%"><strong><i><?=$errorCode?>: </i></strong></td>
<td width="50%"><?=$errorMessage?></td>
</tr>
<?php
}
else {
?>
<tr class="title">
<td colspan="2" height="25"><P><strong> <?=$gatewayCode?></strong></P></td>
</tr>
<tr>
<td align="right" width="50%"><strong><i>Result: </i></strong></td>
<td width="50%"><?=$result?></td>
</tr>
<?php
}
?>
<!-- Response Fields -->
<tr class="title">
<td colspan="2" height="20"><P><strong> JSON Response</strong></P></td>
</tr>
</table>
<table width="50%" align="center" cellpadding="5" border="0">
<tr>
<td><p>The display of the below response is intended to be for this example only. In your integration, you should parse this response to extract and use the response fields required.</p>
</td>
</tr>
<tr>
<td align="center" width="100%">
<textarea rows="40" cols="118" name="outContent" id="outContent"><?=$response?></textarea>
</td>
</tr>
<!-- The below Java Script & HTML formats the JSON output result to make it clean
and readable. You should not use these scripts to format or expose the
JSON response in your integration, but rather store/use any of the
specific fields required for your integration -->
<tr>
<td align="center" width="100%">
<p>Note: The above response has been formatted to make it easier to read. The reformatting also changes amounts to be strictly defined JSON numbers. This means 0's are removed from after the decimal place i.e. 1.00 is displayed as 1 and 1.10 is displayed as 1.1. Click here to display the unformatted JSON Response</p>
</td>
</tr>
<script type="text/javascript" src="./assets/json2.js"></script>
<script type="text/javascript" src="./assets/jsonformatter.js"></script>
<script type="text/javascript" src="./assets/jquery-1.3.2.js"></script>
<script>
var orginalJSON = $("#outContent").val();
function FormatTextarea() {
var sJSON = $("#outContent").val();
var oJSON = JSON.parse(sJSON);
sJSON = FormatJSON(oJSON);
$("#outContent").val(sJSON);
}
FormatTextarea();
function displayRawJSON() {
$("#outContent").val(orginalJSON);
}
</script>
</table>
<br/><br/>
</body>
</html>
3-D Secure (3DS) is a separate workflow that occurs before the authorization. As a prerequisite, your merchant account needs to support 3DS. During checkout, first you will get the 3DS response. If the card supports 3DS and fails authentication, then you should display an error message to the cardholder. Otherwise, if the 3DS authentication is successful or undetermined, you can proceed to the authorization step.
There is a separate integration document for 3-D Secure Authentication

PHP reload elements without reloading the page?

I have code generating a table from a database like this:
<?
include 'conndb.php';
?>
<button id="ps">PŚ</button>
<button id="lgp">LGP</button>
<table align=center border=1 cellspacing=0 cellpadding=2 style=\"color: brown;\">
<tr>
<td width=25 align=\"center\">Lp.</td>
<td width=570 align=\"left\">Nazwisko i imię</td>
<td width=50 align=\"center\">Pkt</td>
</tr>
<? ///content
$sql55="SELECT * FROM `grobar_IDs` WHERE `ps_m_s`!=0 AND `kategoria`=1 ORDER BY `ps_m_s` DESC LIMIT 5";
$result55=mysql_query($sql55);
$lp0 = 1;
while($s = mysql_fetch_assoc($result55)) {
echo "<tr><td width=25 align=\"center\">".$lp0++."</td><td width=570 align=\"left\">".$s['nazwisko']." ".$s['imie']."</td><td width=50 align=\"center\">".$s['ps_m_s']."</td></tr>";
}
///end content
?>
</table>
And I want to change the content between ///content and ///end content after using these buttons - of course without reloading the page. How can I do this?

Email is send on loading of the app script, but email needed to be send onclick

I have created an app script in which email can be send to the login user and to the email Ids which are mentioned in spreadsheet. The email is send to the active user and to all the mentioned email Ids.
However I want email to be send to login user (which is done) and to the specified email Id when selected via app script.
But the mail is send to all the mentioned email IDs in spreadsheet when the app script is getting loaded, whereas the mail should be send onclick, which is not working.
function doGet() {
return HtmlService
.createTemplateFromFile('index')
.evaluate();
}
function getData() {
return SpreadsheetApp
.openById('SS ID')
.getDataRange()
.getValues();
}
function sendMessage(ManagerID,proNo,proName){
var email=Session.getActiveUser().getEmail();
var eId=ManagerID;
var subject="Feedback form initiated" ;
var message="Feedback form initiated by "+eId;
var message2="To fill the feedback form please follow the url: ";
var url="googleform's ID";
var subject2="Feedback Form";
MailApp.sendEmail(eId, subject, message);
MailApp.sendEmail(email,subject2,message2+url);
}
//index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body onload="document.getElementById('one').style.visibility='hidden'">
<div id="initiateFb">
<form>
<? var data = getData(); ?>
<table border='1px solid black'>
<? for (var i = 0; i < data.length; i++) { ?>
<tr>
<? for (var j = 0; j < data[i].length; j++) { ?>
<td><?= data[i][j] ?></td>
<?if(j==(data[i].length-1)&&i!=0) { ?>
<td><input type="submit" name="submit" value="Initiate"
onclick="document.getElementById('initiateFb').style.display = 'none';
document.getElementById('one').style.visibility='visible';
<?var ManagerID=data[i][6];?> <?var proNo=data[i][1];?> <?var proName=data[i][2];?>
document.getElementById('div1').innerHTML='<?=data[i][1] ?>';
document.getElementById('div2').innerHTML='<?=data[i][2] ?>';
document.getElementById('div3').innerHTML='<?=data[i][3] ?>';
document.getElementById('div4').innerHTML='<?=data[i][4] ?>';
document.getElementById('div5').innerHTML='<?=data[i][5] ?>';
document.getElementById('div6').innerHTML='<?=data[i][6] ?>';
document.getElementById('div7').innerHTML='<?=data[i][7] ?>';
document.getElementById('div8').innerHTML='<?=data[i][8] ?>';
document.getElementById('div9').innerHTML='<?=data[i][9] ?>';
return false;"/>
</td>
<? } ?>
<? } ?>
</tr>
<? } ?>
</table>
</form>
</div>
<div id="one">
<form>
<table>
<tr>
<td>ca :</td>
<td id="div1"></td>
</tr>
<tr>
<td>cb :</td>
<td id="div2"></td>
</tr>
<tr>
<td>cc:</td>
<td id="div3"></td>
</tr>
<tr>
<td>cd :</td>
<td id="div4"></td>
</tr>
<tr>
<td>ce:</td>
<td id="div5"></td>
</tr>
<tr>
<td>cf:</td>
<td id="div6"></td>
</tr>
<tr>
<td>cg :</td>
<td id="div7"></td>
</tr>
<tr>
<td>ch :</td>
<td id="div8"></td>
</tr>
<tr>
<td>ci:</td>
<td id="div9"></td>
</tr>
</table>
<input type="submit" name="submit" value="Initiate Feedback" onclick="<?sendMessage(ManagerID,proNo,proName);?>"/>
</form>
</div>
</body>
</html>
I have attached my code.
arturro is correcct in the question comment. To make an asynchronous call you must use
google.script.run.sendMessage(ManagerID,proNo,proName)
However make note that
<input type="submit" name="submit" value="Initiate Feedback" onclick="google.script.run.sendMessage(ManagerID,proNo,proName)"
will not work because you are doing that within the HTML body. You are better of using a javascript code between <script></script> which would fetch the variables you need and then you can use the google.script.run in order to send out the email.
So you would then have
<script>
function sender() {
var ManagerID, proNo, proName;
//use Document.getElementById in order to populate the variables with
//what you need from the form
google.script.run.sendMessage(ManagerID, proNo, proName);
}
</script>
<input type="submit" name="submit" value="Initiate Feedback" onclick="sender()">
The <script></script> part is supposed to be in your index.html as it is a client side script that will handle the calling of the server side script
I have done something similar and it works fine.

Change dynamic id of an URL

I'm looking a way to set with javascript somewhere only the id e.g from a youtube video and to place it automatic in URL. For instance I can make it like this in PHP: ->
<?php
$id = 'pOYRLBhYGyc';
?>
<table style="background:url('http://img.youtube.com/vi/ <?php echo "$id" ?> /0.jpg')no-repeat;
Is there any way like this in JS also?
Yes you can. You need to set the background property dynamically.
Checkout a sample in JS Fiddle.
<table id="sample" border="1" width="100%" height="100%">
<tr>
<td>Sample</td>
</tr>
<tr>
<td>Sample</td>
</tr>
<tr>
<td>Sample</td>
</tr>
<tr>
<td>Sample</td>
</tr>
</table>
The script tag will contain the following script.
var videoId = "pOYRLBhYGyc";
$("#sample").attr("background", "http://img.youtube.com/vi/" + videoId + "/1.jpg");
http://jsfiddle.net/y44n6hao/

Categories

Resources