473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

javascript postback

How can I do the following using html/javascript

Page 1 has a form with a text field, when you click on a link next to
the textfield it launches page2 where you click on a picture which
returns a value back to page 1 without page 1 reloading.
So basically I want to launch a new page2 from page1 and then return a
value back to the form on page 1.
Please provide a simple example code if possible.
Thanks

Jan 9 '07 #1
2 1862
tr****@gmail.com wrote:
How can I do the following using html/javascript

Page 1 has a form with a text field, when you click on a link next to
the textfield it launches page2 where you click on a picture which
returns a value back to page 1 without page 1 reloading.
So basically I want to launch a new page2 from page1 and then return a
value back to the form on page 1.
Please provide a simple example code if possible.
Thanks
Hi,

You asked this in comp.lang.php yesterday eh? ;-)

Well, that is not diificult.
One straightforward approach:
1) open the new window using window.open()
2) produce in that page your picture and add something like this:
<img src="img1.jpg" onClick="postBack('img1.jpg');"><br>
<img src="img2.jpg" onClick="postBack('img2.jpg');"><br>

And add in the head:
<script type="text/javascript">
function postBack(imgsrc){
opener.imageClicked(imgsrc);
// and maybe close the popup
self.close();
}
</script>
And add in your first page the function imageClicked:

<script type="text/javascript">
function imageClicked(someImage){
alert("You clicked: "+someImage);
}
</script>

regards,
Erwin Moller
Jan 10 '07 #2
Thanks for you help! Here is how I ended up using it:

test.php

<php
....
?>

<form name="f1">
<input type="text" name="t1" value="">
</form>

<P><a href="#null"
onclick="window.open('popup.htm','','top=100,left= 100,width=300,height=300')">open</a>

<?
....
?>
popup.htm

<script>
function putLabel(lbl){
if (opener && !opener.closed) opener.document.f1.t1.value=lbl;
window.close();
}
</script>

<a href="javascript:putLabel('Label 1')">Label 1</a>
<a href="javascript:putLabel('Label 2')">Label 2</a>
<a href="javascript:putLabel('Label 3')">Label 3</a>

Jan 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
2
by: Bruce W.1 | last post by:
There's something I can't figure out. I added some javascript behavior to my datagrid, just like in this article, except in C# instead of VB: ...
21
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script...
2
by: Alan Silver | last post by:
Hello, I have just discovered that if you turn off Javascript, then cross-page posting does not work. The postback goes to the originating page, which basically means that nothing happens. I...
3
by: vinay | last post by:
Hi All I have a page in which i using user control .on user control i using javascript to pop up a message .when i choose wrong date in user control & submits the page it alerts the message of...
4
by: =?Utf-8?B?T3Bh?= | last post by:
Hi, I'm not sure if the title is correct. Here's what I am having trouble with: I have a server side button control where I am calling a javascript function via the OnClientClick property. I...
8
by: Deft.Jab | last post by:
This problem only exists in IE, due to UI restrictions I'm using a href in an error label to bring up a modal popup. I'm using a callback to filter a grid on the popup. The problem: The href...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
2
Frinavale
by: Frinavale | last post by:
JavaScript in ASP.NET Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.