Page 1 of 1

Reload a field without reloading the whole page

Posted: Fri Feb 03, 2006 7:53 pm
by utahfriend
I have written a program where you click on an icon next to a field and a new window opens with a list to choose from. When you click on an item, the new window closes and the information about the item is stored in a variable. Is it possible to make it so when the new window closes, the field changes with the new information without reloading the whole page. If I reload the whole page, all the other items that were changed without being saved is lost!

Here is a snipit of the code:

Code: Select all

<tr>
      <td width="100%" bgcolor="#FFFFFF">
      <div align="left">
        <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="99%" id="AutoNumber3">
          <tr>
            <td width="17%">
            <p align="right"><font face="Verdana" size="2">Choose Logo 1:</font></td>
            <td width="76%"><font face="Verdana">
            <input name=logo_1 size="72" value="<?PHP echo $logo ?>"</font></td>
            <td width="7%">

<a href="select_image.php"> <img border="0" src="http://store.globalmarketingplus.com/images/ig_treeFolder.gif" width="16" height="20"></a> 

            
          </tr>

Posted: Fri Feb 03, 2006 7:58 pm
by josh
You can reference items on the master page from the child page using javascript:

Code: Select all

function setMyField(val)	{
	var currentWin = self;
	var parentWin = currentWin.opener;
	var parentForm = parentWin.document.myForm;
	parentForm.myField.value = manuf;
	parentForm.myField.text = manuf;
	self.close();	
}

Posted: Fri Feb 03, 2006 8:09 pm
by yum-jelly
This really a javascript question.

In your pop windows, say you have selectbox

Code: Select all

<form>
 <select name='junk' id='junk' onchange='loader();'><option value='junk 1'>Junk 1<option value='junk 2'>Junk 2</select>
</form>
In the parent page that opened the popup you have form that has a text input....

Code: Select all

<form>
<input type='text' name='trashcan' id='trashcan' />
</form>

Now to make it all work, add this to the <head>(add here)</head> in your popup window...

Code: Select all

<script type='text/javascript'>
	function loader()
	{
		var from = document.getElementById('junk').value;

		var to = this.opener.document.getElementById('trashcan');

		to.value = from;

		self.close();

		return;
	}
</script>
yj!

Posted: Fri Feb 03, 2006 8:15 pm
by John Cartwright
Moved to Client-Side.