Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1. Get the <form> element
- form = document.querySelector('#create-form');
- console.log(form)
- // 2. Event Listen when form has been submitted
- // // 2.1 Prevent the default behavior of form submission
- form.onsubmit=function(event){
- event.preventDefault();
- // this is prevent any button within the form refresh when being clicked.
- // // write your code her
- console.log("clicked button!");
- // it only apply to button in the form
- // // 2.2 Get the value of <input> elements
- msg= document.querySelector('#input-msg').value;
- img=document.querySelector('#input-img').value;
- // console.log(inputMsg.value) this is to show out the value
- // msg is the name put on the id input-msg
- // img is the name put on the id input-img.these two is named for the future purpose
- console.log(msg);
- // msgVal=msg.value;
- // this is to put value on the function
- // // 2.3 Concatenate the URL string
- homeurl="file:///C:/Users/User/Desktop/disappearing-message-app-boiler-master/message.html"
- url=homeurl + "?img-url=" + img + "&msg=" + msg
- // homeurl is the url that u would like to link on when result is generated. in this case will be the message.html.
- // the "?img-url" and "&msg" is same and act like the conjunction used to connect homeurl and img.
- // // 2.4 Get the <p> element and change it's value to the URL string
- paragraph= document.querySelector('#share-url');
- paragraph.innerHTML=url;
- console.log(paragraph);
- // the purpose of console log is to test whether the command works
- // name the id share-url into paragraph. run the result of html generated in url form
- }
- // window.setTimeout("closetext()",3000);
- // function closetext(){
- // document.querySelector("h1").style.display="none";
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement