Sending data between two forms

Links for php scripts

Moderators: macek, egami, gesf

User avatar
popeye
New php-forum User
New php-forum User
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Sending data between two forms

Postby popeye » Sat Oct 22, 2005 3:35 pm

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: Select all

<?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>";
?>

sanketce
New php-forum User
New php-forum User
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

Postby sanketce » Fri Dec 09, 2005 3:01 am

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 :)

User avatar
Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Postby Coditor » Fri Feb 03, 2006 4:20 pm

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: Select all

<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


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest

cron