Jump to content

interactive popup window type thing?


ShootingBlanks

Recommended Posts

Hello.  I'm wondering how to make it so that when a user clicks a link, that link will open a kind of "on-screen popup window" (I say "on-screen" because I want it to sort of overlay the current window contents - and even ideally sort of "fade out" the original page's contents in the background like you may have seen on some sites, but that's not a necessity).  The window would have an input box with a "SUBMIT" button that would feed the input text to a database.  There would also be a "CANCEL" button to close the popup window.  Because the input text would feed to a database, and the database table that it feeds to would be dependent on the link that was clicked to open the popup window, I would need the on-screen link that initiates the popup window to pass a variable to it.

 

I'm thinking jQuery can accomplish this somehow, but I'm way too novice to get this going on my own, so I'm looking for some startup help.  I wouldn't need any help with the database insert code.  Just with getting the popup window open and pulling in a variable from a clicked link.

 

Thanks so much for any help that can be offered to get me going on this!!!

Link to comment
Share on other sites

Thanks!  I think that's what I'm looking for.  Well, particularly this: http://jqueryui.com/demos/dialog/#modal-form.

 

But the documentation for doing that is pretty bad.  It shows that example, but doesn't really explain it or even show how to associate it with a link/button.  I copied/pasted the example code onto a page, and all the HTML of the popup form just showed on the page (flat - not popped up or anything).

 

Link to comment
Share on other sites

As for it being flat, it sounds like you aren't pointing to the proper jQuery file.

 

About the documentation, it is very good for showing you how to make the modal dialog. What are you having trouble with? How to handle the form? Ajax?

Link to comment
Share on other sites

What are you having trouble with? How to handle the form? Ajax?

 

Much of this may just be my limited novice knowledge of jQuery.  Basically, from what I can tell they use this as an example:

$(document).ready(function() {
var $dialog = $('<div></div>')
	.html('This dialog will show every time!')
	.dialog({
		autoOpen: false,
		title: 'Basic Dialog'
	});

$('#opener').click(function() {
	$dialog.dialog('open');
});
});

 

That gives a popup that has a div that says "This dialog will show everytime!".  I don't want a div, though.  I want a whole other page to show up (the page with the form).  Or, is that stupid?  Should I just have the form on the same page in a div?

 

Anyway, using the code above I can get the dialog box to pop up, but I can't integrate that "modal" code to have the fading in the background.

 

Thanks!

Link to comment
Share on other sites

Put that form in a div, hide the div using style="display:none;" and give it an ID, let's say dialogForm. Then just do this:

$(document).ready(function() {
   $('#opener').click(function() {
      $('#dialogForm').dialog('open');
   });
});

 

Also, it sounds like you are still missing some jQuery files. Are you getting any JS errors?

Link to comment
Share on other sites

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.