Last active
May 28, 2016 18:22
-
-
Save babhishek21/b61a70143b8617f49a59 to your computer and use it in GitHub Desktop.
Simple snippet to autofill the feedback forms of the online NSIT Feedback System.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple snippet to lazy auto fill the short, but boring feedback forms at: | |
* http://nsitfeedbacksystem.elasticbeanstalk.com/ | |
* | |
* Usage: Define this function for the page/window you want to run it on. Call it with valid params. | |
* You can run it on the browser/client JS engine. This does not submit the form. So you can review changes. | |
* | |
* Warning: The function must be defined for each page/reload because the current window changes. | |
* | |
* Edit: Looks like jQuery works. So I've made it shorter! | |
* | |
* @param {int} radio_val Your preferred score from 1-5 on valid radio forms. | |
* @param {String} comment_val Your preffered comments. | |
*/ | |
function lazyBoyFillsBoringForm (radio_val, comment_val) { | |
$('[type=radio][value=' + radio_val + ']').click(); | |
$('#id_comments').val(comment_val); | |
} | |
/** | |
* If the above doesn't work, use this one instead. | |
* After all, Old is Gold. | |
*/ | |
function lazyBoyFillsBoringForm (radio_val, comment_val) { | |
var mylist = document.querySelectorAll("input[type=radio]"); | |
for(var i=0; i<mylist.length; i++) { | |
if(mylist[i].value == radio_val) | |
mylist[i].checked = true; | |
} | |
document.getElementById("id_comments").value = comment_val; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment