Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 05-29-2008, 07:30 AM AJAX problem
Junior Talker

Posts: 1
Name: Ondrej
Trades: 0
Hello.
I have got form for string counting: (http://www.2001.genezis.eu/php_ajax_pokusy/index.html). I need, that result from php script, will be put into yellow DIV element (id="mistoZobrazeni"). Must be with AJAX and without page refresh. Sources:

pocitaj.php

<?

$text = $_GET["text"];

$vyber = $_GET["vyber"];

echo substr_count($text,$vyber);

?>

index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">

<link href="styles.css" rel="stylesheet" type="text/css" />

<title>

test

</title>

<html>

<body>

<script type="text/javascript">

function vyberClanek()

{

var url = document.getElementById("vyber").value;

if (url != 0)

{

if (window.ActiveXObject)

{

httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

}

else

{

httpRequest = new XMLHttpRequest();

}

httpRequest.open("GET", url, true);

httpRequest.onreadystatechange= function () {processRequest(); } ;

httpRequest.send(null);

}

else

{

document.getElementById("mistoZobrazeni").innerHTM L = "";



}

}

function processRequest()

{

if (httpRequest.readyState == 4)

{

if(httpRequest.status == 200)

{

var mistoZobrazeni = document.getElementById("mistoZobrazeni");

mistoZobrazeni.innerHTML = httpRequest.responseText;

}

else

{

alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);

}

}

}

</script>

<form name=f value="pocitaj.php" action="pocitaj.php" method="GET">

<textarea value="text" name=text rows="8" cols="40"></textarea>

<br> Pocet znakov

<select name="vyber" id="vyber">



<option value="a"> a

</option>

<option value="b"> b

</option>

</select>

<input type="submit">

</form>

<div id="mistoZobrazeni">

</div>



</body>

</html>


Can you help me? And sorry for my poor english.
hal_sk is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to AJAX problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08521 seconds with 12 queries