Jump to content

simzam

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

simzam's Achievements

Member

Member (2/5)

0

Reputation

  1. thanks i will post my full code im using ajax Mypage.php <?php session_start(); error_reporting(-1); print <<<EOD <html> <head> <title> Insert Page !</title> </head> <body> EOD; if (!empty($_GET['divid']) && isset($_GET['divid'])){ $getdiv = $_GET['divid'] ; print <<<EOD <script type="text/javascript"> function doHttpRequest() { http.open("POST", "ajaxpost.php", true); http.onreadystatechange = getHttpRes; var params = "ajax1="+ encodeURI(document.getElementById("$getdiv").innerHTML); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.send(params); } function getHttpRes(){ if (http.readyState == 4 && http.status == 200) { var myvar = document.getElementById('ajaxtext'), res = http.responseText; myvar.innerHTML = res; } } function getXHTTP( ) { var xhttp; try { xhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { try { xhttp = new XMLHttpRequest(); } catch (e3) { xhttp = false; } } } return xhttp; } var http = getXHTTP(); window.onload = doHttpRequest; </script> EOD; } if(isset($_SESSION["ajaxtext"])) { $mysession = $_SESSION['ajaxtext']; }else{ $mysession = ""; } $httpquery = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']."insertrow=true" ; if (isset($getdiv)){ $httpquery = str_replace("&divid={$getdiv}", "", $httpquery); list($httpquery) = explode("insertrow=true", $httpquery); $httpquery = $httpquery."insertrow=true"."&" ; }else{ $httpquery = str_replace("&insertinto=true", "", $httpquery); list($httpquery) = explode("insertrow=true", $httpquery); $httpquery = $httpquery."insertrow=true"."&" ; } if ((isset($_GET['insertrow'])) &&($_GET['insertrow']=="true")){ if(isset($_SESSION["ajaxtext"])) { unset($_SESSION['ajaxtext']); $mysession = "New Post !" ; $_SESSION['ajaxtext'] = $mysession ; } } $httpupdate =$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']."insertinto=true" ; if (isset($getdiv)){ $httpupdate = str_replace("&divid={$getdiv}", "", $httpupdate); list($httpupdate) = explode("insertinto=true", $httpupdate); $httpupdate = $httpupdate."insertinto=true"."&" ; }else{ $httpupdate = str_replace("&insertrow=true", "", $httpupdate); list($httpupdate) = explode("insertinto=true", $httpupdate); $httpupdate= $httpupdate."insertinto=true"."&"; } if ((isset($_GET['insertinto'])) &&($_GET['insertinto']=="true")){ if(isset($_SESSION["ajaxtext"])) { unset($_SESSION['ajaxtext']); $mysession = "" ; // here is my issue! $_SESSION['ajaxtext'] = $mysession ; //insertrow() ; } } print <<<EOD Insert: <br> ----------------------------------------------------------> <a href='{$httpquery}' >New</a> <br> <textarea rows='3' cols='40' id='ajaxtext' name ='ajaxtext'>$mysession</textarea><br> ----------------------------------------------------------> <a href='{$httpupdate}'>Insert!</a> EOD; // mysql_connect('localhost','root','******'); // mysql_select_db('fblike', $conn); // here i use my sql 'SELECT * FROM mytable'; echo "<table border= 1><tr>\n"; echo "<th>Title</th>\n"; echo "<th>Edit</th>\n"; echo "<th>Del</th></tr>\n"; while($row = mysql_fetch_assoc($rs)) { if ( !empty($_GET["page"]) && isset($_GET['page']) ){ $pageid = $_GET['page'] ; echo "<tr><td><div id=\"div{$row['id']}\">{$row['title']}</div></td> \n" ; echo "<td><a href= \"?page={$pageid}&divid=div{$row['id']}&\">Edit</a> </td> \n" ; echo "<td><a href= \"#\">Delete</a> </td> </tr> \n" ; } } echo "</table>\n"; echo "<br>\n"; echo "</body>\n"; echo " </html>\n"; ?> ajaxpost.php <?php session_start(); if (isset($_POST['ajax1'])) { $_SESSION['ajaxtext'] = $_POST['ajax1']; echo "{$_SESSION['ajaxtext']}" ; } ?>
  2. how to get text-area text into variable without using <form> i mean can i get through $_GET please provide me solution it needed badly if ((isset($_GET['insertinto'])) &&($_GET['insertinto']=="true")){ if(isset($_SESSION["ajaxtext"])) { unset($_SESSION['ajaxtext']); $mysession = "" ; //my textarea typed data should b here $_SESSION['ajaxtext'] = $mysession ; //insertrow() ; } } print <<<EOD <textarea rows='3' cols='40' id='ajaxtext' name ='ajaxtext'>$mysession</textarea><br> EOD;
  3. kindly tell if i want to explode multiple thing then how to do that this explode insertrow=true and i wanted explode this aswell &divid=div2 if ((isset($_GET['insertrow'])) &&($_GET['insertrow']=="true")){ list($httpquery) = explode('insertrow=true', $httpquery); $httpquery = $httpquery."insertrow=true" ; }
  4. solved ! $httpquery = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']."insertrow=true" ; if ((isset($_GET['insertrow'])) &&($_GET['insertrow']=="true")){ list($httpquery) = explode('insertrow=true', $httpquery); $httpquery = $httpquery."insertrow=true" ; }
  5. my problem is when i click on hyperlink it start copying it self insertrow=yes in address bar how to tackle this $httpquery = "{$_SERVER['PHP_SELF']}?{$_SERVER['QUERY_STRING']}&insertrow=yes" ; <a href='{$httpquery}' >New</a> <br> if (isset($_GET['insertrow'])) { echo "<br> {$_GET['insertrow']} "; }
  6. Please have a look and let me know why its not posting var to php i rechecked many times but cannot figure out ! <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <script type="text/javascript"> function changename() { var ajaxobject; if (window.XMLHttpRequest){ ajaxobject=new XMLHttpRequest(); } else if (window.ActiveXObject){ ajaxobject=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support Ajax!"); } ajaxobject.onreadystatechange=function() { if(ajaxobject.readyState==4 && ajaxobject.status == 200) { var ajaxdisplay = document.getElementById('ajaxDiv') ; var ajaxtextarea = document.getElementById('ajaxtext') ; ajaxtextarea.innerHTML = ajaxdisplay.innerHTML ; } } var ajaxhttpDiv = document.getElementById("ajaxDiv"); ajaxobject.open("POST","ajax.php",true); ajaxobject.setRequestHeader("Content-type","application/x-www-form-urlencoded"); ajaxobject.send('ajax='+ajaxhttpDiv.innerHTML); } </script> <div id="ajaxDiv" >My Div Text</div> <br> <textarea id="ajaxtext" ></textarea> <input name="Submit" id="Submit" value="Submit" onclick="changename()" type="button"> </body> </html> <?php if(isset($_POST['ajax'])) { $text = $_POST['ajax']; echo " <br>{$text}"; } ?>
  7. yes sorry ! here it works properly i sort-out the problem var ajaxdisplay = document.getElementById('ajaxDiv') ; var ajaxtextarea = document.getElementById('ajaxtext') ; ajaxtextarea.innerHTML = ajaxdisplay.innerHTML ; <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <script type="text/javascript"> function changename() { var ajaxobject; if (window.XMLHttpRequest) { ajaxobject=new XMLHttpRequest(); } else if (window.ActiveXObject) { ajaxobject=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support Ajax!"); } ajaxobject.onreadystatechange=function() { if(ajaxobject.readyState==4 && ajaxobject.status == 200) { var ajaxdisplay = document.getElementById('ajaxDiv') ; var ajaxtextarea = document.getElementById('ajaxtext') ; ajaxtextarea.innerHTML = ajaxdisplay.innerHTML ; } } ajaxobject.open("GET","ajax.php?namehere="+document.getElementById('ajaxDiv').innerHTML,true); ajaxobject.send(null); } </script> <div id="ajaxDiv" >My Div Text</div> <br> <textarea id="ajaxtext" ></textarea> <input name="Submit" id="Submit" value="Submit" onclick="changename()" type="button"> </body> </html> <?php if ( !empty($_GET["namehere"]) && isset($_GET['namehere']) ){ echo "{$_GET['namehere']}"; } ?>
  8. I'm Trying to display <div>My Text Div</div> in <textarea>My Text Div</textarea> when i press submit nothing happens <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"> function changename() { //Declare the variable that will hold the XMLHttp Object. var ajaxobject; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari ajaxobject=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 ajaxobject=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support Ajax!"); } ajaxobject.onreadystatechange=function() { if(ajaxobject.readyState==4) { var ajaxDisplay = document.getElementById('ajaxDiv'); var ajaxtextarea = document.getElementById('ajaxtext'); ajaxDisplay.innerHTML = ajaxtextarea.innerHTML ; ajaxtextarea.innerHTML = ''; } } ajaxobject.open("GET","ajax.php?ajax="+ajaxtextarea.innerHTML, true); ajaxobject.send(null); } </script> <div id="ajaxDiv" >My Text Div</div> <br> <textarea id="ajaxtext" ></textarea> <input name="Submit" id="Submit" value="Submit" onclick="javascript:changename()" type="button"></body> </html> <?php if ( !empty($_GET["ajax"]) && isset($_GET['ajax']) ){ echo $_GET['ajax']; } ?>
  9. still not working ! var ajaxDisplay = document.getElementById('ajaxtext'); ajaxDisplay.innerHTML = ajaxobject.responseText; var ajaxtextarea = document.getElementById('ajaxDiv').innerHTML; ajaxobject.open("GET","ajax.php?name="+ajaxtextarea, true); ajaxobject.send(null); <div id="ajaxDiv" >My Text Div</div> <br> <textarea id="ajaxtext" ></textarea>
  10. how to access div using innerhtml i'm kinda noob example would b helpful
  11. simply when i press Submit My Text Div should set on <textarea>
  12. yes ! so i need to change ? .innerhtml
  13. haY tell me where im doing wrong its not sending mydiv text to <textarea> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <script type="text/javascript"> function changename() { //Declare the variable that will hold the XMLHttp Object. var ajaxobject; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari ajaxobject=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 ajaxobject=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support Ajax!"); } ajaxobject.onreadystatechange=function() { if(ajaxobject.readyState==4) { document.getElementById('namehere').innerHTML = ajaxobject.responseText; } } ajaxobject.open("GET","ajax.php?name="+document.getElementById('name').value,true); ajaxobject.send(null); } </script> <textarea id="namehere" name="namehere"></textarea> <div id="name" name = "name">My Text Div</div> <br> <input name="Submit" id="Submit" value="Submit" onclick="javascript:changename()" type="button"></body> </html> <?php if ( !empty($_GET["name"]) && isset($_GET['name']) ){ echo $_GET['name']; } ?>
  14. I'm trying this but its not even working ! textarea should remember previous text value on refresh of page if(isset($_SESSION["quote1"])) $mysession= $_SESSION["quote1"]; else $mysession= ""; echo "Insert Row: <br> <textarea rows=\"1\" cols=\"60\" name=\"quote1\" id= \"textarea12\" wrap=\"physical\" value= \"$mysession\"> \n"; echo "</textarea> \n";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.