Şimdi Ara

Goole sheets ve google web app dropdown menu

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
2
Cevap
0
Favori
739
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Merhaba hanımlar beyler, çok acemiyim ve bir kod üzerine çalışıyorum. Google sheet ve Goole web app kullanıyorum. Goole web appteki dropdown menuyu google sheete yazdırmaya çalışıyorum. Youtubedan bir kod buldum ve biraz uğtaştıktan sonra çalışır hale getirebildim .


    İstediği 2 ayrı dropdown menu yapıp bu menulerdeki seçimlerin doğru şekilde google sheete otomatik yazılmasını sağlamaya çalışıyorum. 2. dropdown menuyu çalıştıramıyorum.


    https://imgur.com/a/FunKxLR


    https://imgur.com/a/b4hWWGM
















    CODE:




    function doGet(request) {


    return HtmlService.createTemplateFromFile('Index')


    .evaluate();


    }




    /* @Include JavaScript and CSS Files */


    function include(filename) {


    return HtmlService.createHtmlOutputFromFile(filename)


    .getContent();


    }




    /* @Process Form */


    function processForm(formObject) {


    var url = "";


    var ss = SpreadsheetApp.openByUrl(url);


    var ws = ss.getSheetByName("DATA");



    ws.appendRow([formObject.first_name,


    formObject.last_name,


    formObject.dateOfBirth,


    formObject.time,


    formObject.email,


    formObject.tour,


    formObject.total_payment,


    formObject.paid,


    formObject.to_pay,


    formObject.currency,


    formObject.phone,


    formObject.new_Date]);


    }




    function doGet(e) {


    var htmlOutput = HtmlService.createTemplateFromFile('Index');


    var tours = getTours();


    htmlOutput.message = '';


    htmlOutput.tours = tours;


    return htmlOutput.evaluate();


    }




    function doPost(e) {



    Logger.log(JSON.stringify(e));



    var tour = e.parameters.tour.toString();




    AddRecord(tour);



    var htmlOutput = HtmlService.createTemplateFromFile('Index');


    var tours = getTours();


    htmlOutput.message = 'Record Added';


    htmlOutput.tours = tours;


    return htmlOutput.evaluate();



    }




    function getTours() {


    var ss= SpreadsheetApp.getActiveSpreadsheet();


    var lovSheet = ss.getSheetByName("LOV");


    var getLastRow = lovSheet.getLastRow();


    var return_array = [];


    for(var i = 2; i <= getLastRow; i++)


    {


    if(return_array.indexOf(lovSheet.getRange(i, 1).getValue()) === -1) {


    return_array.push(lovSheet.getRange(i, 1).getValue());


    }


    }






    return return_array;


    }




    function getFruits(tour) {


    var ss= SpreadsheetApp.getActiveSpreadsheet();


    var lovSheet = ss.getSheetByName("LOV");


    var getLastRow = lovSheet.getLastRow();


    var return_array = [];


    for(var i = 2; i <= getLastRow; i++)


    {


    if(lovSheet.getRange(i, 1).getValue() === tour) {


    return_array.push(lovSheet.getRange(i, 2).getValue());


    }


    }






    return return_array;


    }




    function AddRecord(tour) {


    var url = ''; //URL OF GOOGLE SHEET;


    var ss= SpreadsheetApp.openByUrl(url);


    var dataSheet = ss.getSheetByName("DATA");


    dataSheet.appendRow([tour, new Date()]);


    }




    function getUrl() {


    var url = ScriptApp.getService().getUrl();


    return url;


    }




    HTML:


    <!DOCTYPE html>

    <html>

    <head>

    <base target="_top">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <?!= include('JavaScript'); ?>

    </head>

    <body>

    <div class="container">

    <div class="row">

    <div class="col-6">

    <form id="myForm" onsubmit="handleFormSubmit(this)">

    <p class="h4 mb-4 text-center">Define Tur Kayıf Formu</p>


    <div class="form-row">

    <div class="form-group col-md-6">

    <label for="first_name">First Name</label>

    <input type="text" class="form-control" id="first_name" name="first_name" placeholder="First Name">

    </div>

    <div class="form-group col-md-6">

    <label for="last_name">Last Name</label>

    <input type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name">

    </div>

    </div>


    <div class="form-row">

    <div class="form-group col-md-6">

    <label for="dateOfBirth">Date of Birth</label>

    <input type="date" class="form-control" id="dateOfBirth" name="dateOfBirth">

    </div>

    </div>

    <div class="form-group">

    <label for="email">Email</label>

    <input type="email" class="form-control" id="email" name="email" placeholder="Email">

    </div>



    <div class="form-group">

    <label for="total_payment">Total Payment</label>

    <input type="text" class="form-control" id="total_payment" name="total_payment" placeholder="Total Payment">

    </div>


    <div class="form-group">

    <label for="paid">Paid</label>

    <input type="text" class="form-control" id="paid" name="paid" placeholder="Paid">

    </div>


    <div class="form-group">

    <label for="to_pay">To Pay</label>

    <input type="text" class="form-control" id="to_pay" name="to_pay" placeholder="To Pay">

    </div>


    <div class="form-group">

    <label for="currency">Currency</label>

    <input type="text" class="form-control" id="currency" name="currency" placeholder="Currency">

    </div>


    <div class="form-group">

    <label for="time">Time</label>

    <input type="text" class="form-control" id="time" name="time" placeholder="Time">

    </div>


    <div class="form-group">

    <label for="phone">Phone Number</label>

    <input type="tel" class="form-control" id="phone" name="phone" placeholder="Phone Number">

    </div>


    <!DOCTYPE html>

    <html>

    <head>

    <base target="_top">

    <script>

    function GetFruit(tour)

    {

    google.script.run.withSuccessHandler(function(ar)

    {


    console.log(ar);

    fruit.length = 0;

    let option = document.createElement("option");

    option.value = "";

    option.text = "";

    fruit.appendChild(option);

    ar.forEach(function(item, index)

    {

    let option = document.createElement("option");

    option.value = item;

    option.text = item;

    fruit.appendChild(option);

    });

    }).getFruits(tour);

    };

    </script>

    </head>

    <body>

    <h1></h1>

    <?var url = getUrl();?>

    <form method="post" action="<?= url ?>" >

    <label style="font-size: 20px" >Tours</label><br>

    <select name="tour" style="font-size: 20px" onchange="GetFruit(this.value)" >

    <option value="" ></option>

    <? for(var i = 0; i < tours.length; i++) { ?>

    <option value="<?= tours[i] ?>" ><?= tours[i] ?></option>

    <? } ?>

    </select><br><br>

    <input type="submit" name="submitButton" value="Submit" style="font-size: 30px" />

    <span style="font-size: 20px" ><?= message ?></span>

    </form>

    </body>

    </html>




    < Bu mesaj bu kişi tarafından değiştirildi Goa Mania -- 23 Ekim 2022; 17:17:37 >







  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.