Question

I've spend a week on this issue and it is probably real simple...

I am using osTicket (open source support ticket system) on my site. I want to use the ticketform as a contact form on one of my pages. I only want to show the form id="ticketForm" (see code below) because I don't want all the rest of the code (menu with Support Center Home, Open New Ticket, Check Ticket Status buttons etc.) from the open.php file - I tried to use an iframe, but too many problems and iframe is not a good way to do it.

I want to use this part (I don't show all the code because I think there is some sensitive information in the code - hope that is okay):

<form id="ticketForm" enctype="multipart/form-data" action="open.php" method="post">
   <input type="hidden" value=......... etc. code for name, email, attachment fields, captcha etc.</form>

from: www.mysite.com...../support/open.php

and show it on: www.mysite.com...../contact.html

so that I get a contact form that blends in with the text I have on that page.

Any simple way to do this? Please be gentle (don't assume that I know things that you take for granted) - I'm no coder :o) Thanks.

Was it helpful?

Solution

In contact.html do the following:

$('#result').load('/path/to/open.php #ticketForm');

that will retrieve the form with id ticketForm from open.php and place it inside the div with id result in your contact.html page.

See the Loading page fragments section of .load() jquery method.

UPDATE:
You should put the above code in the document.ready handler inside the <body> of your contact.html, like so:

<script type="text/javascript"> 
    $(document).ready(function() {
       $('#result').load('/path/to/open.php #ticketForm');
    });
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top