Google Scripts Variable trouble

Viewed 38

I am working on a room reservation system using Google scripts and a spreadsheet. It involves getting information from the user (like their name, email, phone number), and then populating the spreadsheet in their requested row. I want to make the form they fill out in HTML so that I can style it nicely and have all the questions in one spot. I was previously using ui.prompt, but I don't think it's possible to have all the questions on one prompt. When there was only one question per prompt it was very long and perhaps confusing to the user. If I'm wrong here and there is a way to put more than one question on a ui.prompt that would be really helpful to know... Anyway, back to my original question. I have the form already written, but I can't figure out how to transfer the user's input (stored in variables) back to my main script (Code.gs). All the HTML code is in another script called sideBar.html.

Here is the code that I have in HTMl:

<form method="post" id ="get_info" onsubmit="storeInfo">
  <p>
    <label>First and last name:</label>
    <input name="userName" required="required" type="text">
  </p>
  <p>
    <label>Phone number:</label>
    <input name="userPhone" required="required" type="number">
  </p>
  <p>
    <label>Email address:</label>
    <input name="userEmail" required="required" type="email">
  </p>
  <p>
    <label>Are you 'faculty', 'staff', or 'student'</label>
    <input name="typeUser" required="required" type="text">
  </p>
  <p>
    <label>What is your reason for reserving? (meeting, counseling session, other)</label>
    <input name="reasonRes" required="required" type="text">
  </p>
  <p>
    <label>What row would you like to reserve (row ID is to the left of the date column)</label>
    <input name="rowId" required="required" type="number">
  </p>
  <p>
    <label>How many hours would you like to reserve the room for? (30 mins = .5, 1 hour = 1, 1 hour 30 mins = 1.5, etc.)</label>
    <input name="lengthRes" required="required" type="number">
  </p>
  <p>
    <input value="Submit" type="submit">
  </p>
</form>

Any help on how to transfer these variables back to my Code.gs script would be MUCH appreciated! I know this is long, but thank you!!!

0 Answers
Related