אהלן, חבר'ה.
אני מנסה כבר כמה זמן לפתור איזו בעיה שיש לי עם JavaScript.
בעניין הוא כזה, אני צריך לעשות מעין הזמנה ב-HTML שהמשתמש מכניס את הנתונים ואלו יישלחו אל ההזמנה במקומות שלהם.
את הרוב סיימתי, אבל אני לא מצליח לשלוח נתונים מתגית ה-input.
כאשר המשתמש ייכנס לאתר יעלה לו חלון prompt שבו הוא ירשום את שמו, זו תהיה החתימה בסוף ההזמנה. את המידע הזה הצלחתי להעביר להזמנה, אבל את השאר לא.
אני לא מבין למה, ברור שיש משהו שאני מפספס. לכן, הנה אני כאן מבקש את עזרתכם! בכל מקרה, אני ארשום כאן את הקוד עצמו של ה-HTML וה-JavaScript.
<html> <head> <link rel="stylesheet" href="CSS.css"/> <script src="JavaScript.js"> </script> </head> <body onload = "load()"> <span id="invite1">Invite:</span> <input onmouseover="this.value='who is it?';" onmouseout="this.value='';" /> <br></br> <span id="time">Time:</span> <input onmouseover="this.value='when is the event?';" onmouseout="this.value='';" /> <br></br> <span id="place">Place:</span> <input onmouseover="this.value='where is the event?';" onmouseout="this.value='';" /> <br></br> <button onclick= "hideNsee()">GENERATE INVITE</button> <div id="invite2" "send()" style="display: none;"> <div id="date"> 10/3/2015 </div> <h1>Invitation</h1><br></br> <div id="text"> Dear Mr <div id="myName"></div> You are being invited to an annual meeting, regarding to your field of work. Please bring with you all the required documents, to make the meeting productive. if for some reason you cannnot participate in this meeting, you should notify promptly, so we can find you a replacement. The meeting will take place on **send time here**, at **send place here** Please do not be late. </div> Sincerely yours, <div id="myName"></div> </div> </body> </html>
והנה ה-JavaScript:
var answer; var invite; var time; var place; function load() { answer=prompt("what is your name?", "Write your name here"); var idInput = document.getElementById("myName"); idInput.value = answer; } function hideNsee() { var HNS = document.getElementById("invite2"); document.getElementById("myName").innerHTML = answer; if(HNS.style.display == "none") HNS.style.display = "block"; else HNS.style.display = "none"; } function send() { invite = document.getElementById("invite1").innerHTML; document.getElementById("invited").innerHTML = invite; }
אני צריך כעת לשמור את מה שהמשתמש יכניס לתוך ה-invite למשל(הכפתור הראשון) ואז לשלוח את זה(פשוט שיירשם שם) כמו שנרשם בסוף ההזמנה <div id="myName"></div>.
אני מאוד מקווה שאני ברור לגבי הבעיה שלי! אם לא, אנסה להסביר את עצמי טוב יותר.
תודה מראש!