0

I basically want to have a set-up for our gaming community that would really help us out. I have this idea that if you put a certain value into a cell on a Google Spreadsheet, it would give a client-side pop-up box saying something.

Now in the current spreadsheet we use which you can see here: "https://docs.google.com/spreadsheets/d/1QBVvQkkmLJ3Ro2uHAmQm2yulmJ8Tg38p5Ke3YIe-FwI/edit#gid=1161230471". We have Data Validation under the course section. Now essentially, what I want to happen is when a person selects a certain value from that drop down list, it will put a Pop-Up box on their screen explaining key information about the course.

Is this even possible?

Shaun.

Michael
  • 32,527
  • 49
  • 210
  • 370
Shaun Cockram
  • 101
  • 1
  • 2
  • 10

1 Answers1

0

Here is how you do it. Add as many "else if" functions as you want. I formatted it in the it would be easy for you to edit

function onEdit(e) {
  var cell = e.range;
  var cellColumn = cell.getColumn();
  var cellSheet = cell.getSheet().getName();
  var cellValue = e.value;
  var sheet = "System_Info";   //This is here to ignore the System info sheet

  if (cellSheet !== sheet && cellColumn === 4) {
    if (cellValue === "PT1 - Induction Training") {
      Browser.msgBox("This is a training course. (put your message text here)");  //Add the course name and the message that you want to popup. Course name should be exactly the same as in the list (case sensitive)
    } 

    else if (cellValue === "Course 2 name") {
      Browser.msgBox("Pop-up box message");  //// add as many "else if" conditions as you want"
    } else if (cellValue === "Course 3 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 4 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 5 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 6 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 7 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 8 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 9 name") {
      Browser.msgBox("Pop-up box message");   
    } else if (cellValue === "Course 10 name") {
      Browser.msgBox("Pop-up box message");   
    } 


    else if (cellValue === undefined) {  }
    else {
      Browser.msgBox("Please choose a valid course from the lsit");   //This is in case they put a wrong course name
    }
  }
}

UPDATE: If you want to do this on multiple columns, change

if (cellSheet !== sheet && cellColumn === 4) {

To

if (cellSheet !== sheet){
  if {cellColumn === 4 || cellColumn === 5) {
    //the rest of your code
  }
}
Akshin Jalilov
  • 1,658
  • 1
  • 12
  • 12
  • In this bit here: " if (cellSheet !== sheet && cellColumn === 4) {" I'm getting a Syntax Error" Do I have to put anything here, like the sheet? – Shaun Cockram May 14 '15 at 13:58
  • You do not need to run the script. just save it and close the script editor. It will run every time you edit column D. I have just checked with a copy of your spreadsheet and it seems to be working. Try changing one of the boxes in Column D to PT1 - Induction Training and wait for a few seconds. – Akshin Jalilov May 14 '15 at 16:00
  • Ah sweet it works! This is really great and the community is greatful! Just a quick one, if the cell is blank, it says I have entered a invalid course. Is there a way to make blank cells acceptable? – Shaun Cockram May 14 '15 at 18:17
  • Glad I could help you. Yes, I have edited my my code to accommodate for that. Basically add this line in order to not do anything if the value is empty: "else if (cellValue === undefined) { }" – Akshin Jalilov May 14 '15 at 19:16
  • Thankyou Akshin for helping me out! The script works perfectly! – Shaun Cockram May 15 '15 at 09:37
  • I'm back again! Essentially, I also want this to apply to column 5 as well, is that possible? – Shaun Cockram Jun 07 '15 at 19:51