Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // no direct access
- defined('_JEXEC') or die ('Restricted Access');
- JHTML::stylesheet("style.css", JURI::base()."components/com_weddingguestrsvp/css/");
- ?>
- <script type="text/javascript">
- var xhr = false;
- function sendRSVP()
- {
- var valid = true;
- if(document.getElementById('name').value == "" || document.getElementById('name').value == " ")
- valid = false;
- if(document.getElementById('phone').value == "" || document.getElementById('phone').value == " ")
- valid = false;
- if(document.getElementById('email').value == "" || document.getElementById('email').value == " ")
- valid = false;
- if(document.getElementById('number_attending').value == "" || document.getElementById('number_attending').value == " ")
- valid = false;
- if(valid)
- {
- if(window.XMLHttpRequest)
- {
- xhr = new XMLHttpRequest();
- }
- else
- {
- if(window.ActiveXObject)
- {
- try
- {
- xhr = new ActiveXObject("Microsoft.XMLHTTP");
- }
- catch(e){}
- }
- }
- if(xhr)
- {
- var name = document.getElementById("name").value;
- var phone = document.getElementById("phone").value;
- var email = document.getElementById("email").value;
- var number_attending = document.getElementById("number_attending").value;
- document.getElementById("rsvp-div").innerHTML = "Sending RSVP...";
- xhr.onreadystatechange = updateRSVPInfo;
- var data = "name="+name+"&address="+address+"&phone="+phone+"&email="+email+"&number_attending="+number_attending;
- xhr.open("GET", "/index.php?option=com_weddingguestrsvp&task=rsvp&format=raw&"+data, true);
- xhr.send('');
- }
- else
- {
- alert("Sorry, but I couldn't create an XMLHttpRequest");
- }
- return true;
- }
- else
- {
- alert("Please verify that you have entered all information in correctly!");
- }
- }
- function updateRSVPInfo()
- {
- if (xhr.readyState == 4)
- {
- if (xhr.status == 200)
- {
- document.getElementById("rsvp-div").innerHTML = xhr.responseText;
- }
- else
- {
- document.getElementById('rsvp-div').innerHTML = "Sorry couldn't add you to the list";
- }
- }
- return true;
- }
- </script>
- <div id="rsvp-div">
- <fieldset><legend>Personal Information</legend>
- <table>
- <tr><td>Name</td><td><input type="text" id="name" name="name" /></td></tr>
- <tr><td>Phone</td><td><input type="text" size="12" id="phone" name="phone" /></td></tr>
- <tr><td>Email</td><td><input type="text" id="email" name="email" /></td></tr>
- <tr><td>Number Attending</td><td><input type="text" id="number_attending" name="number_attending" /></td></tr>
- <tr><td>Attending:</td><td><input type="radio" name="address" value="nowedding" /><label>Not Attending</label> <input type="radio"
- name="address" value="wedding" /><label>Wedding Only</label>  <input type="radio" name="address" value="wedding_reception" checked/><label>Wedding &
- Reception</label></td></tr>
- </table>
- </fieldset>
- <div id="submit" onclick="sendRSVP()">Send RSVP</div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement