How to's:
I have java script that opens a new window now inside my pop-up window I have list of names display and I want to select the names and insert it on my PHP page text box. Anybody who can show me how to do this?
thanks! -
echo '
-
<h2>' . ( $id ? translate ( 'Edit Entry' ) : translate ( 'Add Entry' ) )
-
. $eType_label . ' <img src="images/help.gif" alt="' . translate ( 'Help' )
-
. '" class="help" onclick="window.open( \'search_contact.php'
-
. ( empty ( $id ) ? '?add=1' : '' )
-
. '\', \'cal_help\', \'dependent,menubar,scrollbars,height=400,width=800,'
-
. 'innerHeight=420,outerWidth=420\' );" /></h2>'
-
20 7250
There no Java in your question; where do you want me to move your question to? A Javascript forum or a PHP forum?
kind regards,
Jos (moderator)
Hi Josah,
Originally I posted this thread on PHP but I was told by Markus to put this on JAVA forum.
Basically after doing the pop-up window I just wanted to grab the variable selected to the other page. I hope I discribe the process I wanted to do well. Now Im looking for answer how to do this.
thanks again
I have java script inside my php that opens a 2nd page window. What I wanted to do is to select the name (for example) from the pop-up window and send the value to my original page on PHP text box. Anybody who can show me how to do this? - echo '
-
<h2>' . ( $id ? translate ( 'Edit Entry' ) : translate ( 'Add Entry' ) )
-
. $eType_label . ' <img src="images/help.gif" alt="' . translate ( 'Help' )
-
. '" class="help" onclick="window.open( \'search_contact.php'
-
. ( empty ( $id ) ? '?add=1' : '' )
-
. '\', \'cal_help\', \'dependent,menubar,scrollbars,height=400,width=800,'
-
. 'innerHeight=420,outerWidth=420\' );" /></h2>'
-
-
-
-
You want to send back the name from pop-up window to opener window.
You should have a event handler on the pop-up window when you will send back the name to opener window. Access your opener document using "opener.document" in pop-up window JavaScript ;)
That's what you wanted ?
@mychikka
Hi,
it definitely isn't a Java question; there's a bit of Javascript in your file but you also mention PHP (on the server side?) It was a mistake to redirect you to this Java forum (there is no Java in the vicinity ;-)
I'll move it to the Javscript forum; good luck.
kind regards,
Jos
Once you have access to the opener window, to set the text box value: - opener.document.getElementById("textboxID").value = val;
where "textboxID" is the ID of the text box and val is the value selected.
Here's what I got after encorporating acecoder's code but it doesn't do anything. By the way I put this script on the pop-up window or second window. Please let me know what im missing. -
echo "<input type='button' value='Select' onclick=window.opener.document.getElementById( 'ContactID' ).value = value_from_contactbox window.close()'>";
-
or should I add any on the main page where it's calling the pop-up window?
Two things:
1. is value_from_contactbox set correctly by the time you click on the button?
2. You need a semi-colon after that statement before window.close().
Hi acoder, the variable im picking is a result of my query that is displayed in a list and I have a select button (below) to catch the value of the row (which is the contactid)
but still not working (sigh*) I hope im almost there. - echo "<input type='button' value='Select' onclick='window.opener.document.getElementById( 'Contact' ).value = '". $row['contactid']."' ";
Sorry to bud in here but I remember something about having to set the name of the parent window for the opener to work....experts if I'm wrong here please correct me :)
Did you set the name of the Parent window before opening the Child window (popup window)?
For example: - <body onload="window.name='ParentWindowName'">
Aside from that, I would recommend that you put your JavaScript in a method instead of directly in the button click event. This is simply easier to read especially if you have "if" statements....for example....Oh! wait a sec...By rewriting your JavaScript into a function I found your problem.
You're attempting to access a variable that exists on the server in your JavaScript code. You cannot access $row['contactid'] in your JavaScript method because this variable exists on the server.
Well, actually this might not be your problem if your list submits the page to the PHP code when the users selects something...then your button would have had the correct values. Regardless, I believe that you have looked over this fact. (Maybe, I should just stick with .NET :) )
Try retrieving the selected value using JavaScript in order to set the text box in your parent page.
For example (the following assumes that you're attempting to print an item selected in a <select> list with the ID = "idOfList"): -
echo "<script type='text/javascript'>"
-
echo " function setTextBoxValue(){"
-
echo " if (window.opener && !window.opener.closed) {"
-
echo " var dropDownList = document.getElementById('idOfList');"
-
echo " var selectedIndex = dropDownList.selectedIndex;"
-
echo " var selectedValue = dropDownList[dropdownIndex].value;"
-
echo " window.opener.document.getElementById('Contact').value = selectedValue ;"
-
echo " }"
-
echo "}"
-
echo "</script>
-
echo "<input type='button' value='Select' onclick='setTextBoxValue();' />"
-
-Frinny
a little progress here... my java is functioning except it didn't catch the value
My Java on to of the <body> tag -
<script language="javascript">
-
function contactid(contactid)
-
{
-
window.opener.document.getElementById( 'Contactid' ).value =textcontactid;
-
window.close();
-
}
-
</script>
MY PHP CODE -- I put the value to pick on the text box - echo "<td><input type='text' name=\"textcontactid\" value='". $row['contactid']. "'>";
-
echo "<input type='button' value='". $row['contactid']. "' onclick=\"contactid()\" >";
RESULT:
[object] --- SHOWS ON MY PARENT WINDOW TEXT BOX
please help :(
and my parent input box looks like this.... - echo "<td width='100%'>
-
<input type=\"text\" name=\"contactid\" onclick=\"window.open('contact_search_sub.php')\"></input>";
A few things:
1.. Watch out for the case. "contactid" and "Contactid" are NOT the same.
2. The number of parameters has to be correct.
3. In your function, you have textcontactid, but you've not set it anywhere. I would suggest passing the value in the function, e.g. when calling the function, you could use "contactid(this.form.textcontactid.value)"
3. In your function, you have textcontactid, but you've not set it anywhere. I would suggest passing the value in the function, e.g. when calling the function, you could use "contactid(this.form.textcontactid.value)"
Hi Acoder... how can i set a parameter if the value is from a query result.
eg. ". $row['contactid']. "
thank you
But then this could be changed by the user (since it's a text box). For example, if you had "test" in the text box as returned by the query and then the user modified it to be "test1", the value that the text box in the parent page should be set to is "test1". In other words, use the value at the time the user presses the button, not the value when the page loaded.
Hi Acoder...
let set I assigned the query result on a textbox or i make it type= 'hidden' - echo "<td><input type='text' name=\"txtcontactid\" value='". $row['contactid']. "'>";
can i call it on my function? - echo "<input type='button' value='select' onclick=\"contactid($txtcontactid)\" >";
how can i assignedt he txtcontactid from the input box to a var?
Yes, a bit of PHP: - echo "<input type='button' value='select' onclick=\"contactid('". $row['contactid']. "')\" >";
as you used to display the value in the text box.
If the value doesn't change, you don't need a text box.
acoder...
did i get it correctly? im having page error ont he pop-up window now. Below are the codes page by page.
parent window - <input type=\"text\" name=\"contact\" value=\"$contact\" onclick=\"window.open('contact_search_sub.php')\"></input>";
pop-up window java - <script language="javascript">
-
function contactid(contactid)
-
{
-
window.opener.document.getElementById( 'contactid' ).value =contact;
-
window.close();
-
}
-
</script>
-
pop-up window select button - echo "<td><input type='button' value='select' onclick=\"contactid('". $row['contactid']. "')\" >";
what am i missing here? sigh*
Do you have an element on the parent page with ID "contactid"?
The line: - window.opener.document.getElementById( 'contactid' ).value =contact;
should be - window.opener.document.getElementById( 'contactid' ).value =contactid;
because contact won't be defined. contactid is the parameter passed to the function which will be defined.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Raymond Hettinger |
last post by:
Found in a pamphlet at a pre-school:
---------------------------------------
Reading improves vocabulary
Reading raises cultural literacy through shared knowledge
Reading develops writing skills...
|
by: jblazi |
last post by:
Let us assume I have a list like
and would like to transoform it into the string
'{1,2},{7,8},{12,13}'
Which is the simplest way of achiebing this? (The list is in fact much
longer and...
|
by: Roy Smith |
last post by:
In the recent "transforming a list into a string" thread, we've been
discussing the fact that list.pop() is O(1), but list.pop(0) is O(n). I
decided to do a little timing experiment. To be sure,...
|
by: M. Clift |
last post by:
Hi All,
Could someone help me out with this?
items = ('a', 'b', 'c', 'd')
items + 1 = ( 'b', 'c', 'd', 'a')
items + 2 = ( 'c', 'd', 'a', 'b')
items + 3 = ( 'd', 'a', 'b', 'c')
trans = 1
|
by: bearophile |
last post by:
This is my first Python program (it's an improvement of a recursive
version by Luther Blissett). Given a list like this:
, ]]]
It produces the "flatted" version:
I think this operation is...
|
by: AMRaymo |
last post by:
Can someone guide me in the right direction on how to enqueue and
dequeue/pop and push within a linked list? I've figured out the basic
idea, but getting the other options in it seems ot be a...
|
by: metaperl.etc |
last post by:
The following program does not work if you uncomment #lis =
+ list(args)
Evidently Python is opting for the nullary constructor list() as
opposed to the other one which takes a sequence....
|
by: Daniel Nogradi |
last post by:
The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
|
by: bahoo |
last post by:
Hi,
I have a list like
and as output I want
If I
myList.remove('0024')
then only the first instance of '0024' is removed.
|
by: Mikle |
last post by:
I need to update values in a table (where they are null or zero) with
values from another table for the corresponding PopulationMemberID.
Now I now that you can't update where there is a join.....
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |