I have some buttons containing different contents and when the user clicks, a new window should popup with the content for the clicked button.
There should only be one popup window where the content should be altered, depending on which button the user has pressed.
I'm using PHP to generate HTML code but I can't find a way to do it as PHP is server side..
Don't want to use href in html, JS could work, although I'm not great at JS..
Here is a site that will auto-generate javascript code for a popup window that you can attach to your buttons
Related
Is it possible to take the user where the cursor is after reloading the page? I'm enabling a <textarea> on the basis of some URL parameters on page reload using PHP. But in the new window the textarea will open on the bottom of the page. If the page is already lengthy the textarea will be hidden beneath.
Is there any way so that after reloading the page the textarea appears on the viewport so that it can be filled?
I tried:
Write
...
<a href="#ok">#<a> <!-- setting a bookmark to get the viewport here -->
<textarea><textarea>
I know there are plenty of solutions using AJAX, using lightbox etc. But I need a generic way, may be HTML or a server-side solution. Or, in a nay-say it can be jQuery.
It doesn't appear that you are using the anchor (or bookmark, as you called it) correctly. If you give the <textarea> tag an id of "ok" you should be able to link directly to that area of the page by using the # in your link to the page. Example: somepage.html#ok
There is no need to use the <a> tag to create an anchor. That is outdated.
I want to open a popup on pageload .In this popup people can fill data in dropdown for city and locality.
After closing this popup this data should be sent to my parent window where I have a form which contain city and locality textbox.
No I want to implement this using php and javascript.pls suggest.
Put this echo code at php end of child window,
echo '<script type="text/javascript">
window.opener.function_name_of_parent_window('.json_encode($user_data).');
window.close();
</script>';
That will call your desired function on parent window and data that you want to send over there as parameter
I would suggest modal windows (because now browsers block onload popups) and ajax. PHP here is not required, as everything can be implemented in client side
You should with javascript be able to set a variable on the parent page using:
parent.data = localdata
however, why do you want to use a popup window in the first place. A popup layer would be much cleaner and wouldn't be blocked by popup blockers
I have a form which is overlayed over the visitors current page using jQuery when the user clicks on a div in the bottom right of a web page. This overlay pulls up an iframe but I need to record the page the visitor clicked from to get to the overlay (essentially the HTTP_REFERER) along with the resolution of the window the user clicked from.
As of now I am attempting to grab this information after the form has been passed, my concern is that the information I will be provided with will not not be correct and will instead give me the window size of the overlay and since it's a separate iframe won't be able to grab the HTTP_REFERER. Are these assumptions correct?
Can you create a hidden field in the form?
If so you could then update this hidden field with the url of the page the user came from.
var current_url = window.location.pathname;
$('#myHiddenField').val(current_url);
You can get the parent window res with js: parent.document.body.clientHeight/Width
Hi... I want to know that when a user posts a comment to my site ... to open a web page (in new window, with a fixed width and height like window.open ) which contains the form and after submit, I want to close that windows and show that comment in the parent page through ajax ... (or i guess after closing that window, to auto reload the parent page ... I don't know ) ...
Is there any solution to this .. ?
Or what is the best way to open a pop-up which contains the form (not a new window) ?
Thank you very much.
Attach an onclick handler on whatever you use to let the user make a comment
This handler pops up the new window with the form
The form submits the comment to the server via ajax
Once the ajax handler is done on the server, it returns the comment's ID to the form window script
the form window script calls a function in the original window, passing in the comment ID, telling the window to load up the new comment (via another AJAX call, or directly passing the comment details from the form page)
the form page script then closes the window.
on the popup window form tag add target="_PARENT"
on the popup window change the submit button to normal button.
on the popup window, when button clicked, submit the form with js and close the window.
document.formname.submit();
this.close();
in this case your popup window is just to get data then the data will be posted to the main window...
You can access the parent window by using the window.opener JavaScript property. More info here
Does it have to be a new window? Why not a modal form? Take a look at this basic jQuery modal form.
I want to open a popup window on client PC where I will show records. The user will click on the selected row, and the popup window will disappear, but the parent Form on my page must get filled with the DB values related to the clicked row on the popup.
This is what I want to do. What is the right approach?
You should be able to send back some response to your parent window from popup window.
There is a specific javascript methods to do this. See this.
You can also use a modal popup type container which will make communication simpler and give you more control of the data. It'll also work flawlessly even if the client has any sort of popup blocker (which most do by default).
It's easy to build from scratch and there are also many jquery plugins that make it even simpler.