thenelson
asked on
str_replace not working in php script
I have a line in a php script that is working fine:
document.getElementById("t ocall").va lue = $_GET["number"];
When I change it to:
document.getElementById("t ocall").va lue = str_replace("tel:", "", $_GET["number"]);
The line does not work: the field "tocall" does not get filled in and lines after that line do not run.
I get no error messages. I cannot figure out what is wrong.
echo str_replace("tel:", "", "1234"); works fine in an online php emulator but it doesn't work in my script.
Perhaps you can see something I missing?
Thanks
document.getElementById("t
When I change it to:
document.getElementById("t
The line does not work: the field "tocall" does not get filled in and lines after that line do not run.
I get no error messages. I cannot figure out what is wrong.
echo str_replace("tel:", "", "1234"); works fine in an online php emulator but it doesn't work in my script.
Perhaps you can see something I missing?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please post a URL link to this web page so we can use "view source" to see the same thing the browser is seeing, thanks.
ASKER
You're right. It's been quite a while since I worked with php, favascript and html in the same file so I didn't see this is javascript. Thanks for the dope slap.
So I changed php str_replace to java:
document.getElementById("t ocall").va lue = $_GET["number"].replace("t el:", "");
still didn't work. Then I tried:
var str = $_GET["number"];
document.getElementById("t ocall").va lue = str.replace("tel:", "");
still didn't work.
Here is the code around that line:
<script type="text/javascript">
...
window.onload=setTimeout(f unction StartFunction()
{
var $_GET = <?php echo json_encode($_GET); ?>;
if (typeof($_GET["number"]) != "undefined" && $_GET["number"] !== null)
{
document.getElementById("t ocall").va lue = $_GET["number"];
document.getElementById("c all").clic k();
}
if (typeof($_GET["digits"]) != "undefined" && $_GET["digits"] !== null)
{
document.getElementById("d igits").va lue = $_GET["digits"];
}
}, 1000)
</script>
So I changed php str_replace to java:
document.getElementById("t
still didn't work. Then I tried:
var str = $_GET["number"];
document.getElementById("t
still didn't work.
Here is the code around that line:
<script type="text/javascript">
...
window.onload=setTimeout(f
{
var $_GET = <?php echo json_encode($_GET); ?>;
if (typeof($_GET["number"]) != "undefined" && $_GET["number"] !== null)
{
document.getElementById("t
document.getElementById("c
}
if (typeof($_GET["digits"]) != "undefined" && $_GET["digits"] !== null)
{
document.getElementById("d
}
}, 1000)
</script>
ASKER
>Please post a URL link to this web page so we can use "view source" to see the same thing the browser is seeing, thanks.
It's a php script so you won't be able to see it. It's also in a secured folder. But i did post a section of the code.
It's a php script so you won't be able to see it. It's also in a secured folder. But i did post a section of the code.