Sending data between two forms

A

Anonymous

Guest
I am having problem sending the value of the <input> of this page to another <input> in the form "vgetinfo" using the following JS. Can you check it and see hwere the problem is? Thanks


Code:
<?php
$i_vname='x20051010';
echo "
<html>
<head>
<script type='text/javascript'>
function SendVariable(theForm,i_vname) { 
  if (window.opener && !window.opener.closed) {
		 data = document.theForm.i_vname.value;
		 window.opener.document.vgetinfo.i_vdate.value = data;
		 window.close();
  }
}
</script>
</head>
<title>Schedfind</title>
<LINK href='.\css\Stylesheet.css' rel='stylesheet' type='text/css'>
<body>
<form name='Schedfind' method='POST'>
<input type='button' value='2005-10-10' name='$i_vname' ondblclick='SendVariable(this,$i_vname)'>
</form>
</body>
</html>";
?>
 
Your code is seeming ok, so just try something different i.e. use hidden to store your value and use getElementById("") in place of document.form method to retrieve the same. hope your good luck :)
 
A couple of things:

• If you do SendVariable(this,$i_vname) from a button, it won't send the form as first parameter like your function expects it to be. To send the form as first parameter, use this.form.
• x20051010 may be your field name, but it's not a PHP variable. You have to pass it as a string (\"$i_vname\"). However, you need to modify your function to handle the string.

This would be a lot easier and doesn't require any PHP:
Code:
<html>
<head>
<script language="javascript" type="text/javascript">
function sendVariable(sendValue) {
   if (window.opener && ! window.opener.closed) {
      window.opener.document.getElementById("i_vdate").value = sendValue;
      window.close();
   }
}
</script>
</head>
<body>
<input type="button" value="2005-10-10" ondblclick="sendVariable(this.value);" />
</body>
</html>

Coditor
 
Back
Top