This topic is locked

Using a webservice data to fill fields

3/22/2010 7:00:04 PM
PHPRunner General questions
R
rodny author

Hello,

I'm new using PHPRunner 5.2 and I'm creating a form where I need to access a external web service os postal code from my country (Brasil) to fill other fields in the same from.

Works like this:

1 - I type the postal code (CEP)

2 - a javascript code search in a external datasource and retuns the street name, City, etc (here is the javascript code)

3 - the field are filled.
I know how to make it work in simple html, but it's not working in PHPRunner 5.2
Please I need your help guys...
Thanks in advance
Rodny <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=14119&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

Sergey Kornilov admin 3/22/2010

You need to tell what exactly doesn't work. You can also post your app to Demo Account and open a ticket at at http://support.xlinesoft.com.

R
rodny author 3/23/2010



You need to tell what exactly doesn't work. You can also post your app to Demo Account and open a ticket at at http://support.xlinesoft.com.


Hi,

Sorry I couldn't explain myself clearly,

actually the function is not filling the fields how it was supose to do.
First when editing the Add page in html in phpr, I call the .js file like this:

<script src="consulta.js" type=text/javascript></SCRIPT>


Then with a link I call the function like this:

<A style="CURSOR: pointer" href="javascript: funcaowebservicecep();">Complete Fields</A>


In the same folder of the php file I have the two files that I called, the .js and .php
Here is the javascript consulta.js code:



function getHTTPObject() {

var xmlhttp;

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

try {

xmlhttp = new XMLHttpRequest();

} catch (e) {

xmlhttp = false;

}

}

return xmlhttp;

}

var http = getHTTPObject();
function funcaowebservicecep()

{

http.open("GET", 'buscarendereco.php?cep='+document.getElementById("cep").value, true);

http.onreadystatechange = handleHttpResponse;

http.send(null);
var arr; //array com os dados retornados

function handleHttpResponse()

{

if (http.readyState == 4)

{

var response = http.responseText;

eval("var arr = "+response); //cria objeto com o resultado

document.getElementById("rua").value = arr.rua;

document.getElementById("bairro").value = arr.bairro;

document.getElementById("cidade").value = arr.cidade;

document.getElementById("uf").value = arr.uf;

}

}

}


Here is the php buscarendereco.php file:



<?

$consulta = 'http://viavirtual.com.br/webservicecep.php?cep='.$_GET["CEP";];

$consulta = file($consulta);

$consulta = explode('||',$consulta[0]);
$rua=utf8_encode($consulta[0]);

$bairro=utf8_encode($consulta[1]);

$cidade=utf8_encode($consulta[2]);

$uf=$consulta[4];

?>{"rua":"<? echo $rua; ?>","bairro":"<? echo $bairro; ?>","cidade":"<? echo $cidade; ?>","uf":"<? echo $uf; ?>"}


I hope i made myself clear, than you
Rodny <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=48695&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

Sergey Kornilov admin 3/23/2010

Rodny,
sorry, cannot tell what might be wrong looking at this code.
I recommend to post your application to Demo Account and open ticket at http://support.xlinesoft.com sending your application URL.

R
rodny author 3/23/2010



Rodny,
sorry, cannot tell what might be wrong looking at this code.
I recommend to post your application to Demo Account and open ticket at http://support.xlinesoft.com sending your application URL.


Hello,

I posted my aplication and opened a ticked number. 204046
Thanks
Rodny <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=48721&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />