View Full Version : PHP, javascript n xhtml -- compare variable problem
cstan
08-30-2006, 01:58 PM
i got a parent window that call out the child window......
in the child window i successful get the value from the parent window by using opener.document.getElementById.
because i want show the xhtml based on the value i get, so i had using PHP to compare with the language i get.
but the problem now is i cant compare although the value same as i get.
for example:
in parent window:
<input type = "hidden" name = "text1" id = "text1" value = "abc">
in child window:
<? $getValue = "<script language = 'language'>document.write(opener.document.getElementById('text1').value);</script>";
if($getValue == "abc")
{
echo"<table><tr><td>same</td></tr></table>";
}
else
{
echo "<table><tr><td>different<td></tr></table>";
}
?>
but the problem now is, it always show "different" message. y like that de??
i try to show d $getValue 's value, it show out "abc".
anyone can help me n tell me what is the problem??
thanks
Er, because the string "<script language = 'language'>document.write(opener.document.getElementById('text1').value);</script>" is not equal to the string "abc".
It's not parsed into "abc" until it reaches the client, by which time your PHP has executed.
Also, don't use client-side XHTML. See http://www.hixie.ch/advocacy/xhtml.
cstan
08-31-2006, 01:09 PM
Er, because the string "<script language = 'language'>document.write(opener.document.getElementById('text1').value);</script>" is not equal to the string "abc".
It's not parsed into "abc" until it reaches the client, by which time your PHP has executed.
Also, don't use client-side XHTML. See http://www.hixie.ch/advocacy/xhtml.
be4 i aslo thinks about that, so i try print out the value i get...
it print out the value as "abc".
actually the process for me is got a page that alre show out. i want summary the info in other pages.
so is can work with php.
it print out the value as "abc".No, it prints out the value "<script language = 'language'>document.write(opener.document.getElementById('text1').value);</script>". The browser converts this to "abc".
cstan
09-04-2006, 01:26 PM
No, it prints out the value "<script language = 'language'>document.write(opener.document.getElementById('text1').value);</script>". The browser converts this to "abc".
o..icic
then isnt we can compare with the other value???
i try compare with variable with javascript, it work. But if compare with PHP variable then cant work wo..
You can't compare them with PHP, no, unless you call an external Javascript interpreter or something. Even then, you wouldn't be able to use the value of the textbox, to which the server-side interpreter would have no more access than PHP does. You can compare them with Javascript:
<script type="text/javascript">
if(opener.document.getElementById("text1").value == "$getValue")
doSomething();
else
doSomethingElse();
</script>... or, you can submit the form then compare them with PHP on the next page.
cstan
09-05-2006, 11:14 PM
You can't compare them with PHP, no, unless you call an external Javascript interpreter or something. Even then, you wouldn't be able to use the value of the textbox, to which the server-side interpreter would have no more access than PHP does. You can compare them with Javascript:
<script type="text/javascript">
if(opener.document.getElementById("text1").value == "$getValue")
doSomething();
else
doSomethingElse();
</script>... or, you can submit the form then compare them with PHP on the next page.
this only final soluition can be done on it.....
is passing 2 next page then d user may said so trouble..... n i also feel that trouble.....
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.