Jump to content
nurfnose

Submit a form to a lightbox from a link

Recommended Posts

I am trying to have a link submit some form data to a lightbox ( I am using facebox) and am having some trouble. The basic code I am working with is:

<form name="form" method="post" action="test.asp"><ul><li><a  href="#" onclick="document.forms['form'].dept.value = 'ACC'; document.forms['form'].course.value = '115'; document.form.submit('test.asp');" rel="facebox">ACC 115 Payroll Accounting</a></li></ul><input type="hidden" value="" name="dept" id="dept"><input type="hidden" value="" name="course" id="course"></form><script type="text/javascript">$('a[rel*=facebox]').facebox({ loading_image: '/images/loading.gif', close_image: '/images/closelabel.gif' });</script>

This file submits to the test.asp file which processes the XML data which the course descriptions live.

<%dim dept, coursedept = "ACC"course = "115"Set objxml = Server.CreateObject("Microsoft.XMLDOM")objxml.async = falseobjxml.load (Server.MapPath("classes.xml"))set ElemClass = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']")set ElemTitle = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']/title")set ElemDescription = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']/description")set ElemPrereqs = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']/prereqs")%><!DOCTYPE html><html><head><meta charset="utf-8"><title><% Response.Write(dept&" "&course) %></title></head><body><%For i=0 To (ElemClass.length -1)%><h3><% Response.Write(ElemTitle.item(i).Text) %></h3><p><% Response.Write(ElemDescription.item(i).Text) %></p><p><% Response.Write(ElemPrereqs.item(i).Text) %></p><%nextSet objxml = Nothing%></body></html>

I have gotten everything to work, except I can't seem to get the form to put the test.asp in the lightbox. Help please!!

Share this post


Link to post
Share on other sites

You won't be able to submit the form directly to the lightbox. It can load external files via ajax, so the best you can do is submit your form via ajax, get the response that the form was submitted successfully, and manually open the lightbox and point it to an external file that can show the submission results.

Share this post


Link to post
Share on other sites

Maybe I'm missing something, or not completely understanding... My processing page takes the user input to display the appropriate xml node on the fly. How can I store their input to bring it up later?

Share this post


Link to post
Share on other sites

You would need to save the XML data somewhere, like the session or a database or a file. The session is temporary, the database and file would require periodic cleanup to remove old entries unless you saved the files in the server's temp directory. But you just need to save it somewhere and have the next ajax request to load the results indicate which result set to show. If it's stored in the session only then you wouldn't need to indicate which one, there would only be one. If the data in the form is small enough then you can also just gather the form data and send the ajax request with the form data instead of submitting the form normally.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...