javascript - Building value of a variable by looping through form fields -


It comes to AJX / JS, and specific method (functions) / functions S) I seek to achieve this task I am doing

Please be bare with me if you have been asked about time after the time of similar questions, and I hope you have enough information here to help you find the right answers.

Outline

I am currently creating a form for a specific page, where users can suggest suggestions about the content of the Amani page. Are there.

This form is displayed inside the model dialog box, and allows the user to take their suggestions without page.

Of course, I am preparing a code for reuse - write once, use a lot of people - provide a uniform method of form design and deposits without writing the code anywhere on the site Please.

Environment

The site is hosted on the IIS6 server, pages are in ASP, and sending form data

< Strong> problem

The Model Talk Box works as a behavior, and uses to submit from within the model.

Nett uts + script It is designed in such a way that you need to define all your formats which can be passed in your formmail script.

Every time you want to use it, how do you var datastring are added to make sure that how much caffeine was done by you Or the number of painful users knocking at your door opens to simple mistakes that you can take for hours, diagnosis and right.

Then each field is compiled into a variable named Data String:

  var dataString = 'name =' + name + '& amp; Email = '+ email +' and phone = '+ phone;  

Ajax then kicks, and stores the data on the script, and a successful message will appear within the defined defined part of the result:

  $ Ajax ({type: "post", url: "/_global/assets/scripts/formmail/formmail.asp", data: data string, success: function () {$ ('# contact_form') .html ("& lt; $ ('& Lt; h2 & gt; suggestion received & lt; / h2 & gt;') .append ("& lt; p & gt; Thank you, your ID (& lt; p & gt; recommended & Lt; / p & gt; ") .hide () .Fedine (1500, work () {$ ('# message'). Attachment (" & lt; img id = ' Checkmark 'src =' images / check.png '/ & gt; ");});} ....  

desired result

This piece of code is reusable globally To create, and var datastring is populated using a field names and values ​​using the loop.

Then, my partner overflow - please point it in the right direction

Er - Can you add $ ('Serialize () after the data after you: then the result is data: $ (' # contact_form ' ). Serialize () Or am I wrong with your questions?


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -