Jump to content

Recommended Posts

Hey guys I am very frustrated with this code.  I'm trying to write it to where you have a textbox, you click on a link/button and a child window pops.  When you click on something from the child window it adds it to the textbox on the parent form.  I am using a mix of javascript and php because the items on the child window is pulled from a db.  The script pieces are below. 

 

this is the java from the parent

<SCRIPT LANGUAGE="JavaScript">
function openChild(file,window) {
    childWindow=open(file,window,'resizable=yes,scrollbars=yes,width=500,height=600');
    if (childWindow.opener == null) childWindow.opener = self;
    }
</SCRIPT>

 

This is the form from the parent, im trying to paste it to the textbox named "details".  I want to add to what ever they are typing and not replace it.

<form method="POST" action="proc3.php" name="catering">
<table cellpadding=5 border=0 width=80% align=left>
<tr>
<td><b>Name</b></td>
<td><input type=text name="name" size=50 class="form"></td>
</tr>
<tr>
<td><b>Phone</b></td>
<td><input type=text name="phone" size=25 class="form"></td>
</tr>
<tr>
<td><b>Email</b></td>
<td><input type=text name="email" size=50 class="form"></td>
</tr>
<tr>
<td colspan=2 valign=top><b>Catering Request Description <INPUT TYPE="button" VALUE="(MENU)" onmouseover="" onClick="openChild('menusub.php','win2')" class="menusubhead"></td></tr>
<tr>
<tr>
<td></td>
<td>
<input type=hidden name="subject" value="Catering Service" size=50 class="form">
<textarea name="details" id="details" cols="50" Rows="12" style="font-size:15px; border:solid; font-family:Bradley Hand ITC, Book Antiqua, Arial; border:solid 1px; background-color:transparent;"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type=submit class="submit" value="Send Message" style=""></td>
</tr>
</table>
</form>

 

This is the script from the child window

<SCRIPT LANGUAGE="JavaScript">
var myarray_child = new Array ();

function updateParentArray() {
    opener.document.catering.details.value = (myarray_child);
}

</SCRIPT>

 

 

This is the information being pulled from the db that should be placed in the textbox.  When i click it, it does send it, however it over writes everything in the box and its only pulling up the last result from the table.  There are five things pulled from this db and I can only get it work for one. 


$result = mysql_query("SELECT * FROM menu WHERE category='Antipasti' AND status='current'");

while($row = mysql_fetch_array($result))
{

echo"<tr><td>
<SCRIPT LANGUAGE='JavaScript'>
myarray_child='$row[1]'
</SCRIPT>
<INPUT TYPE='SUBMIT' value='$row[1]' class='menusubhead' onClick='updateParentArray()'>
<font class='subhead'><b>$$row[4]</b></font><br></font>
<font class='menutext'>$row[2]</font>
</tr></td>";

}

 

 

I appreciate any help i can get!!  I am very frustrated and I have been at this for two days!!  I spent my entire day on looking through coding websites to get help and Im stilled coming up short.  Thanks guys!

Link to comment
https://forums.phpfreaks.com/topic/237695-help-im-so-frustrated-with-this-code/
Share on other sites

I have been struggling to get this problem fixed.  I am trying to click on a link in a child window and have it add information to a textbox in a parent window.  I have gotten close through some Javascript, but its still not working correct.  The main problem is that the information on the child window is pulled from a database and wont cooperate with the javascript.  I appreciate any help I can get on this one, thanks ya'll.

sorry forgot

 

parent script and

<SCRIPT LANGUAGE="JavaScript">
function openChild(file,window) {
    childWindow=open(file,window,'resizable=yes,scrollbars=yes,width=500,height=600');
    if (childWindow.opener == null) childWindow.opener = self;
    }
</SCRIPT>

</head>

<body>

<form method="POST" action="proc3.php" name="catering">
<table cellpadding=5 border=0 width=80% align=left>
<tr>
<td><b>Name</b></td>
<td><input type=text name="name" size=50 class="form"></td>
</tr>
<tr>
<td><b>Phone</b></td>
<td><input type=text name="phone" size=25 class="form"></td>
</tr>
<tr>
<td><b>Email</b></td>
<td><input type=text name="email" size=50 class="form"></td>
</tr>
<tr>
<td colspan=2 valign=top><b>Catering Request Description <INPUT TYPE="button" VALUE="(MENU)" onmouseover="" onClick="openChild('menusub.php','win2')" class="menusubhead"></td></tr>
<tr>
<tr>
<td></td>
<td>
<input type=hidden name="subject" value="Catering Service" size=50 class="form">
<textarea name="details" id="details" cols="50" Rows="12" style="font-size:15px; border:solid; font-family:Bradley Hand ITC, Book Antiqua, Arial; border:solid 1px; background-color:transparent;"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type=submit class="submit" value="Send Message" style=""></td>
</tr>
</table>
</form>

 

 

child window

<SCRIPT LANGUAGE="JavaScript">
var myarray_child = new Array ();

function updateParentArray() {
    opener.document.catering.details.value = (myarray_child);
}

</SCRIPT>

</head>

<body>

include("database.php");

mysql_select_db("db369261593", $con);

$result = mysql_query("SELECT * FROM menu WHERE category='Antipasti' AND status='current'");

while($row = mysql_fetch_array($result))
{

echo"<tr><td>
<SCRIPT LANGUAGE='JavaScript'>
myarray_child='$row[1]'
</SCRIPT>
<INPUT TYPE='SUBMIT' value='$row[1]' class='menusubhead' onClick='updateParentArray()'>
<font class='subhead'><b>$$row[4]</b></font><br></font>
<font class='menutext'>$row[2]</font>
</tr></td>";

}

 

The child window has about 5 or six of the above code repeated for each section.

 

I just put in the snippets, if you need more please let me know. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.