I am looking to transmit an array through $.ajax and retrieve it within a traditional asp page

I am working with an array that contains the ids of cities collected from a select input field

var city = $('select[name="city"] :selected').map(function(){return $(this).val();}).get();

My goal is to send this array to a classic ASP page, where it will be inserted into a database using the following code:

for each city in Request.Form("city")
    Set rsaddcity = Server.CreateObject("ADODB.Recordset")
    rsaddcity.Open "city_project", conn, 1, 2
    rsaddcity.AddNew
    rsaddcity.Fields.Item("cityid").Value = city
    rsaddcity.Fields.Item("projectid").Value = projectid
    rsaddcity.Update
    rsaddcity.Close()
    Set rsaddcity = Nothing
next

Answer №1

citiesArray = split(Request.Form("city"),",")
projectsArray = split(Request.Form("project"),",")
for index = 0 to ubound(citiesArray)
    Set cityRecordset = Server.CreateObject("ADODB.Recordset")
    cityRecordset.Open "city_project", conn, 1, 2        
    cityRecordset.AddNew
    cityRecordset.Fields.Item("cityid").Value = citiesArray(index)
    cityRecordset.Fields.Item("projectid").Value = projectsArray(index)
    cityRecordset.Update
    cityRecordset.Close()
    Set cityRecordset = Nothing
next

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When an express pre-remove signal initiates another pre-remove action during the removal process

Imagine having 4 different models structured like this: ┌────────────┐ ┌────────────┐ │ User │ │ Goal │ ├────────────┤ 1 ├───── ...

Iterate through the JSON response and send it back to Jquery

I'm almost done with my first jQuery autocomplete script and just need some assistance in understanding how to make the found elements clickable as links. Here is a snippet of my JavaScript code: $(document).ready(function() { var attr = $(&apos ...

In what way can an item be "chosen" to initiate a certain action?

For example, imagine having two containers positioned on the left and right side. The left container contains content that, when selected, displays items on the right side. One solution could involve hiding elements using JavaScript with display: none/in ...

Tips for resolving the issue of "Unable to assign property '_DT_CellIndex' to undefined in Jquery Datatable"

<?php if(mysqli_num_rows($result)>0) {?> <table class="table table-striped" id="example" align="center"> <tr> <thead> <th style=&quo ...

How do I avoid using an if statement in jQuery to eliminate errors caused by "undefined" values?

Whenever I incorporate third-party plugins, my usual practice is to initiate them in the main application.js file. For example: $('.scroll').jScrollPane(); However, a challenge arises when a page loads without the presence of the scroll class, ...

The function onClick does not function properly when used with the <p> element, but it works flawlessly with the <button> element

export function SignoutButton() { return ( <p onClick={() => signOut({ callbackUrl: "/" })}> <IoIosLogOut /> Logout </p> ); } I was struggling with a function in my next.js project that wasn't wo ...

What is the best way to obtain a list of all product names?

I need to extract only the names of the objects (cat, dog, bird) /// Names of objects I want to retrieve /// var storage = [ {cat: {name: "Garfield", count: 3443, price: 1000}}, {bird: {name: "Eagle", count: 4042, price: 3000}}, {dog: {nam ...

Using Grails with AJAX: remoteLink results in a page redirect instead of updating the specified div

I am facing an issue with creating an ajax-enabled web application using the g:remoteLink<code> tag. Instead of updating the specified div, it redirects the whole page to my template.</p> <p><strong>This is what I have implemented: ...

How can I update my htaccess file to serve a php/json version instead of php/html when the request is made via XMLHttpRequest?

I'm in need of assistance: I currently have a situation where I have both a /php_html/request.php and a /php_json/request.php. The goal is to rewrite the rule so that if the request is made using XMLHttpRequest, the result should be /php_json/request. ...

transmit JSON array data to recipient using PHP mailer

I'm facing an issue with my PHP form mailer that uses JSON and AJAX to send data array. The problem is that the mail is being sent without the data, even though I have validated the JSON string to confirm it contains the necessary information. Below ...

The communication between Ajax and django views appears to be incomplete as the data is

Just completed the necessary parts. Being a beginner, please excuse any shortcomings in the question :). Below is my Html code: <div class="form-group row pt-3 d-flex justify-content-center"> <div class="col-sm-10 d-fle ...

Unveiling the Power of Ionic and React for Component Repetition

I'm having trouble figuring out how to repeat my component multiple times using react in Ionic. Can someone assist me with this? Here's an example: In my Component.tsx file, I have the following code: import React from 'react'; import ...

Transform HTML into a Vue component dynamically during runtime

Currently, I am in the process of learning Vue and working on a simple wiki page project. The raw article data is stored in a JSON file written using custom markup. For example, the following markup: The ''sun'' is {r=black black} shoul ...

Content from a plain text file, enhanced with the powerful combination of Happstack and

I am currently working on a Happstack-built website where I need to retrieve and display "user submitted" plain text files. The goal is to simply get the content of the file without the need for server-side storage. How can I achieve this functionality ...

Finding the Client's Private IP Address in React or Node.js: A Comprehensive Guide

Issue I am currently facing the challenge of comparing the user's private IP with the certificate's IP. Is there a method available to retrieve the user's private IP in react or node? Attempted Solution After attempting to find the user&a ...

What is the best way to access the req.user variable from Passport in client-side JavaScript?

I have successfully implemented Passport authentication in my Express application and everything is working perfectly. On my index page, I am displaying req.user as follows: <% if (!isAuthenticated) { %> <a id="signIn" href="/login">Sign I ...

During a submission attempt, Formik automatically marks all fields as touched

I'm facing a problem where a warning is displayed when I try to submit a form because every field is marked as formik.touched=true - this warning should only appear when the name field is changed. I've attempted to remove/add onBlur (some online ...

Incorporate live Twitch streaming onto a web platform

I'm currently in the process of making a website for a friends twitch stream and I'm very confused as to how I implement the twitch stream. I have created a div with the class "Twitchscreen" but I have no idea how I link to the twitch API or get ...

What are the drawbacks of setting data from computed properties?

When working with vuex, I often come across a scenario where I receive an object like the following: user: {name: 'test'} In my app.vue file, I access this object using this.$store.getters.user computed: { user: function() { let user ...

The order of execution in AngularJS: Understanding the flow

I have taken over the responsibility of managing someone else's website, and while going through the codebase, I came across a snippet that looks like the one below (with some code omitted for simplicity): var Application = (function ($, global) ...