Made a javascript

Added javascript to shorten the code.