Jump to content
LaurenWilson

Step by step jQuery commands

Recommended Posts

I'm doing my first ever website and have found this site to be a fantastic resource. I've got to a step now that I thought would be really easy but is apparently rather complex.

 

I need images in Zoo Effects Galleriffic Gallery to to take the user to a page where they have to input their name and email address before downloading an attached specification.

I am using WordPress with the theme Masterful Business (by PandaThemes) which has a jQuery processor. I'm told I need to write the command into the jQuery, however I have no idea how to do this or where to insert the information that I found to do it? can anybody help me out by explaining it in simple terms please? I've found this information, I just need the hows and whats!

 

function post(url, params, urlEncoded, newWindow) {var form = $('<form />').hide();form.attr('action', url).attr('method', 'POST').attr('enctype', urlEncoded ? 'application/x-www-form-urlencoded' : 'multipart/form-data');if(newWindow) form.attr('target', '_blank');function addParam(name, value, parent) {var fullname = (parent.length > 0 ? (parent + '[' + name + ]') : name);if(value instanceof Object) {for(var i in value) {addParam(i, value[i], fullname);}}else $('<input type="hidden" />').attr({name: fullname, value: value}).appendTo(form);};addParam('', params, '');$('body').append(form);form.submit();}

 

Thanks, Lauren

Share this post


Link to post
Share on other sites

Which parts of that process do you have working now, and what still needs to be done? It looks like that code is a function that will add parameters to a form and submit it.

Share this post


Link to post
Share on other sites

chances are you will break a lot of things until you get it right. at least make a copy of the file and then start working on it, so we can help you out.

Share this post


Link to post
Share on other sites

Yeah, I wouldn't suggest making changes to the live site until it's finished and tested. Make a copy that you can work on, even if it's just a few files.

 

I'm not familiar with most of the specific software that you're using, but it sounds like these are the basic steps:

 

Attach click events on the images, if they aren't already there, to either go to a new page with the form on it or display the form in a lightbox or however you want that to show up.

 

The form would have fields for name and address, and it needs to submit to a PHP page to process the form. There are a few options to choose from there.

 

One option is to submit the form via ajax, and the form would process the input data (you haven't mentioned what you want to do with the name and email address), and then it would either output an error message if there was a problem, or it would output the URL of the file they are trying to download. The ajax response handler would need to be able to detect if it got an error message or URL back, and either display the error message or redirect to the URL.

 

The other option is to submit the form normally without ajax, and the form processor would again validate the data, and either show the form again with error messages or redirect to the URL to download.

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...