Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

javascript - Allow Multiple Files Upload on Google Apps Script -Not working

I have created an HTML web app form to allow submitter to submit the data with attachment (multiple files) attachment and maths function is not working. However, I am able to record the form data in the sheet.

I want to allow submitter to submit data from form and attachment links should be updated in sheet.

Please help me to identify fix the issue.

Script is attached below, Google Sheet

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('index').setTitle("Testing");
}


function getOAuthToken() {
  DriveApp.getRootFolder();
  Logger.log(ScriptApp.getOAuthToken())
  return ScriptApp.getOAuthToken();

}


function getCurrentUserEmail()
{
  var email={'email':Session.getActiveUser().getEmail()};//returned as an object
  return email;
}


function saveDate(data) {
    var openSpreadSheet = SpreadsheetApp.openById("1fA5qPNfoegZoEpl1al3XudNEyvomgAbko5XDBA_i7aw").getSheetByName("Sheet1");
    var sheetHeader = openSpreadSheet.getRange(1, 1, 1, openSpreadSheet.getLastColumn()).getValues()[0];
    Logger.log(sheetHeader);
    var arrayToSave = [];
    data["Timestamp"] = Utilities.formatDate(new Date, "IST", "dd/MM/yyyy hh:mm:ss");
    data["Email Address"] = Session.getActiveUser().getEmail().toString();
    for (i = 0; i < sheetHeader.length; i++) {
        if (Object.keys(data).indexOf(sheetHeader[i]) != -1) {
            arrayToSave[i] = data[sheetHeader[i]];
        } else {
            arrayToSave[i] = "";
        }
    }       
    openSpreadSheet.appendRow(arrayToSave);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>123</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">

<!--Icons-->
	<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    

<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->

 <style>
  /*.form-group.num, .form-group.txt {
	  margin-bottom:0; width:100px; display:block; clear:both; margin:0 auto}
	  .form-group.txt { width:inherit;}*/
	  th {    text-align: center;
    background-color: #e3f2fd;color:#263238 !important}
	tr.one th{   
    background-color: #f5f5f5;color:#263238 !important}
	
		
.navbar-brand {
  padding: 0px;
}
.navbar-brand>img {
  height: 100%;
  padding: 15px;
  width: auto;
}
.navbar-default { background-color:#0a3474}
.navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:focus, .navbar-default .navbar-nav>.active>a:hover {
    color: #0a3474;
    background-color: #FFF;
}
.navbar-default .navbar-nav>li>a{
	color:#fff}
	.navbar-default .navbar-nav>li>a:focus, .navbar-default .navbar-nav>li>a:hover{
		 color: #0a3474;
    background-color: #FFF;
		}
.gap10{
	height:10px; display:block; clear:both;}

th {
    text-align: center;
    background-color: #009e16;
    color: #fff !important;}

		
  </style>


<style>

  #attachmentTable{ 
  background: white;
  }
  tr th,tr td{
  text-align: center;
  }
</style>
</head>

<body>
<div class="container">
<div class="row">
  <nav class="navbar navbar-default">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar1">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href=""><img src="" alt="Dispute Bills">
        </a>
        
      </div>
              <ul class="nav navbar-nav navbar-right">
      <li><a href="#"><span class="glyphicon glyphicon-user"></span> : <h9 id="email"></h9></a></li>
     
    </ul>
        </div>

  </nav>
  
  </div>
  
</div>


<hr>
<form name="newpurchase" action="" method="post" enctype="application/x-www-form-urlencoded">
<div class="container">
  <table class="table table-bordered" style="width:65%;margin:0 auto">
    <thead>
      <tr>
        <th  colspan="4">Procurement Request Form</th>
      
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Request Type	</td>
        <td>
        <div class="form-group">
        <select name="supplier_name" class="form-control select" id="RequestType">
								<option value="Supply">Supply</option>
								<option value="Service">Service</option>
								<option value="Software">Software</option>
								
							</select></div></td>
        <td>Urgency</td>
        <td> <div class="form-group"><select name="supplier_name" class="form-control select"id="Urgency" >
								<option value="Low">Low</option>
								<option value="Medium">Medium</option>
								<option value="High">High</option>
								<option value="Critical">Critical</option>
								
							</select></div></td>
      </tr>
      <tr>
        <td>Requester For</td>
        <td> <div class="form-group"><select name="supplier_name" class="form-control select" id="RequestFor" >
								<option value="Cost for Approval">Cost for Approval</option>
								<option value="PO Process">PO Process</option>
								
							</select></div></td>
        <td>Currency</td>
        <td> <div class="form-group"><select name="payment_mode" id="select"  class="form-control select" >
								<option value="INR">INR</option>
								<option value="USD">USD</option>
							</select></div></td>
      </tr>
      <tr>
        <td>Requester Name	</td>
        <td>
<div class="form-group"><input type="text" name="contact_person" class="form-control input-md"  id="RequesterName"/></div></td>
        <td>Business User</td>
        <td><input type="text" name="contact_person" class="form-control input-md"  id="BusinessUser"/></td>
      </tr>
      <tr>
        <td>Short Description:</td>
        <td><textarea class="form-control input-md" id="ShortDescription" name="address_line2"></textarea></td>
        <td>Business Reason:</td>
        <td><textarea class="form-control input-md" id="BusinessReasonforRequestPurpose" name="address_line2"></textarea></td>
      </tr>
    </tbody>
  </table>
</div>
<hr>

<div class="container">
  <td><table id="productList" class="table table-bordered">
    
      <tr>
        <th  colspan="9">Requested Material/Service Details-Cost</th>
      
      </tr>
    
    <tbody>
      <tr id="head">	
        <td>SR No</td>
        <td>Product/Material/ServiceDescription</td>
        <td>Make & Model No</td>
        <td>UOM</td>
        <td>Unit Price</td>
        <td>Quantity</td>
        <td>Total Price	</td>
        <td>GST%	</td>
        <td>Total Price with GST	</td>
      </tr>
      <tr> 
       <td  align="center">1</td>  
						<td><div class="form-group"><input class="form-control input-md" name="purchase_description" type="text" id="ProductMaterialServiceDescription1"></div></td>
						<td><div class="form-group"><input class="form-control input-md" name="on_hand" type="text" id="MakeModelNo1"></div></td>
						<td> <div class="form-group"><select class="form-control " name="productname" id="UOM1" >
                                <option value=""></option>
                                <option value="">Nos</option>
								<option value="">Set</option>
								<option value="">LS</option>
                                <option value="">Per MDY</option>
								<option value="">Per Month</option>
								<option value="">Per Year</option>
							</select></div></td>
						<td><div class="form-group"><input class="form-control input-md"  class="price" data-a-sign="` " data-w-empty="zero" type="text" id="UnitPrice1"name="price"/></div></td>
						<td><div class="form-group"><input class="form-control input-md"  class="qty" type="text" data-a-sign="%" data-p-sign="s" data-w-empty="zero" id="QTY1"name="qty"/></div></td>
						<td><div class="form-group"><input class="form-control input-md"   class="subtot" type="text" data-a-sign="%" data-p-sign="s" data-w-empty="zero" id="Price1"name="subtot"/></div></td>
						<td><div class="form-group"><input class="form-control input-md"  class="gst" data-a-sign="` " data-w-empty="zero" type="text" id="GST1" name="gst"/></div></td>
                        <td><div class="form-group"><input class="form-control input-md" class="total" data-a-sign="` " data-w-empty="zero" type="text" id="TotalPrice1"name="total"/></div></td>
                       
      </tr>
       <tr> 
 <td  align="center">2</td>  
						<td><div class="form-group"><input class="form-control input-md" name="purchase_description" type="text" id="ProductMaterialServiceDescription2"></div></td>
						<td><div class="form-group"><input class="form-control input-md" name="on_hand" type="text" id="MakeModelNo2"></div></td>
						<td><div class="form-group"><select class="form-control " name="productname" id="UOM2" >
                                <option value=""></option>
                                <option value="">Nos</option>
								<option value="">Set</option>
								<option value="">LS</option>
                                <option value="">Per MDY</option>
								<option value="">Per Month</option>
								<option value="">Per Year</option>
							</select></div></td>
						<td><div class="form-group"><input class="form-control input-md"  class="price" data-a-sign="` " data-w-empty="zero" type

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...