Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="jquery-1.10.2.js"></script>
- <script language="JavaScript">
- function get_XmlHttp() {
- // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value)
- var xmlHttp = null;
- if(window.XMLHttpRequest) { // for Forefox, IE7+, Opera, Safari, ...
- xmlHttp = new XMLHttpRequest();
- }
- else if(window.ActiveXObject) { // for Internet Explorer 5 or 6
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- return xmlHttp;
- }
- // sends data to a php file, via GET and POST, and displays the received answer
- function ajaxrequest(php_file, tagID) {
- var request = get_XmlHttp(); // call the function for the XMLHttpRequest instance
- // create pairs index=value with data that must be sent to server, via POST
- var d_post = 'content='+document.getElementById('broadcast').value+'&submit=1'+'&enable_text='+document.getElementById('enable_text').value+'&status='+document.getElementById('status').value;
- //var d_post = 'submit='+document.getElementById('submit').value+'&content='+document.getElementById('content').value+'&status='+document.getElementById('status').value+'&enable_text='+document.getElementById('enable_text').value;
- request.open("POST", "list.php", true); // sets the request
- // adds a header to tell the PHP script to recognize the data as is sent via POST
- request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- request.send(d_post); // sends the request
- // Check request status
- // If the response is received completely, will be transferred to the HTML tag with tagID
- request.onreadystatechange = function() {
- if (request.readyState == 4) {
- document.getElementById('list').innerHTML = request.responseText;
- }
- }
- }
- function toggle(source)
- {
- checkboxes = document.getElementsByName('option[]');
- for(var i=0, n=checkboxes.length;i<n;i++)
- {
- checkboxes[i].checked = source.checked;
- }
- }
- function toggleDisabled(_checked)
- {
- document.getElementById('broadcast').disabled = _checked ? false : true;
- }
- </script>
- <table>
- <tr>
- <th><input type="checkbox" onClick="toggle(this)" /></th>
- <th>test</th>
- <th>test</th>
- <th>test</th>
- </tr>
- </table>
- <div id="list"></div>
- <form action="list.php" method="post" name="form2" onsubmit="ajaxrequest('list.php', 'content'); return false;">
- <p>Texte:
- <input type="checkbox" id="enable_text" name="enable_text" onchange="toggleDisabled(this.checked)"/>
- Status:
- <select name="status" id="status">
- <option VALUE="waiting" selected="selected"> en attente</option>
- <option VALUE="solved"> résolu</option>
- <option VALUE="closed"> clos</option>
- </select>
- <input id="submit" type="submit" value="Send" />
- </p>
- <textarea disabled id="broadcast" name="content" rows="4" cols="80"></textarea>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement