Page 1 of 1

Passing value of a variable

Posted: Fri Sep 18, 2009 3:31 pm
by Gian
I apologyze for writing again, but I realized that my previous email was not clear enough to illustrate the problem.
I report here the file "sample.php":

<html>
<head>
<script>
function doIt()
{
factory.printing.leftMargin = .25;
var marleft=factory.printing.leftMargin;
var deltaleft = 25.4 * (marleft-.25);

fr1.focus();
factory.printing.Print(true,fr1);
}
</script>
</head>
<body>

<!-- MeadCo smsx -->
<object id='factory' viewastext style='display:none'
classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814'
codebase='smsx.cab#Version=6,5,439,12'>
</object>

<form name="inputform" action="sample.php" method="post">
<?
$box++;
echo "<input type='text' name='box' value='$box' >" ;

$deltaleft = document.inputform.deltaleft;
echo "<input type='hidden' name='document.inputform.deltaleft' value='$deltaleft' >" ;

?>
<input type='submit' onclick='doIt()'>
</form>

<iframe name="fr1" id="fr1" src="pop.html"></iframe>

</body>
</html>

By clicking on the form button the program runs the script, computing the var "deltaleft".
Now I would like to pass this variable sitting on the script into the body, in order then to pass the value of this variable to the Iframe file pop.html.
Unfortunately the Iframe does not show this value (most likely because the value is not being passed).
In this case is not a passing from one page to the next, but rather from a page script into another portion of the same page.
(For calculating "deltaleft" I use an object from the UK company MeadCo, which calculates the margin setting within a paper page).
The following is the Iframe source "pop.html" :

<html>
<body>
<script>

box = parent.document.inputform.box.value;
document.write("box = "+box);

deltaleft = parent.document.inputform.deltaleft.value;
document.write ("deltaleft = "+ deltaleft);

</script>
</body>
</html>

Thank you every person for any support or hint etc
Regards
Gian

Passing variable OK, but "if conditional" not working !

Posted: Mon Sep 21, 2009 1:24 pm
by Gian
Hurray, I found out the best way to pass variables between different files: just set a cookie for the variable, then read the same "cookied" variables from a different file !!
My God, but then another problem occurred to me (another one....), which has nothing to do with cookies, that's all been buried, thanks God.

Some thing funny happened on a conditional script coding which DOES NOT occur !!
The following file "sample.php":

<html><head>

<script>
function doIt()
{ factory.printing.Print(true,fr1); }
</script>

</head><body>

<!-- MeadCo smsx -->
<object id='factory' viewastext style='display:none'
classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814'
codebase='smsx.cab#Version=6,5,439,12'>
</object>

<form name="inputform" action="sample.php" method="post">
<?
$box++;
echo "<input type='text' name='box' value='$box' >" ;
?>
<input type='submit' onclick='doIt()'>
</form>

<iframe name="fr1" id="fr1" src="pop.html"></iframe>

</body></html>

works perfectly, I do get the paper printing on the frame, namely "box = 1", then clicking on button "box = 2", etc
Now I wanted to allow the printing ONLY when there isn't any clicking on the form box.
Then I added an "if conditional" statement, where By click the flag is set to true and the printing should be hindered.
The following is the modified script:

<html><head>

<script>
function flag()
{ flag=true; }
</script>

<script>
function doIt()
{ factory.printing.Print(true,fr1); }
</script>

</head><body>

<!-- MeadCo smsx -->
<object id='factory' viewastext style='display:none'
classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814'
codebase='smsx.cab#Version=6,5,439,12'>
</object>

<form name="inputform" action="sample.php" method="post">
<?
$box++;
echo "<input type='text' onclick='flag()' name='box' value='$box' >" ;
?>
<input type='submit' onclick='doIt()'>
</form>

<iframe name="fr1" id="fr1" src="pop.html"></iframe>

</body></html>

Unfortunately I do NOT get the printing in BOTH cases, that is, when the flag is true as well as when the flag is false !!!
Quite ackward, isn't it ?
I have been trying and trying to proof check, it seems like the "if statement" is disregarded !!
Thanks for every expert that could help or hint, I just feel there is something in the parsing that is not accepted.

The following is the file "pop.html" (the source of the iframe).

<html><body><script>

box = parent.document.inputform.box.value;
document.write("box = "+box);

</script></body></html>


Regards
Gian