1

I have an array I've created in JavaScript. The end result comes out to element1,element2,,,element5,element6,,,element9.... etc

Once passed to ColdFusion, it removes the null elements, I end up with element1,element2,element5,element6,element9

I need to maintain these spaces, any ideas? My problem may begin before this, to explain in more detail...

I have a form with 13 elements that are acting as a search/filter type function. I want to "post" with AJAX, in essence, i'm using a button to call a jQuery function and want to pass the fields to a ColdFusion page, then have the results passed back. The JavaScript array may not even be my best option.

Any ideas?

1
  • Nevermind, i'm just going to post the form and reload the page, not the easiest use of ajax... Commented Oct 24, 2008 at 15:56

4 Answers 4

5

Are you deserializing the jS array into a list? CF ignores empty list fields using its built-in functions. This can be worked around by processing the text directly. Someone has already done this for you, fortunately. There are several functions at cflib.org, like:

etc, etc, etc.

Sign up to request clarification or add additional context in comments.

Comments

0

In exchanging data between javascript and coldfusion have a look at using JSON.

http://www.json.org

http://www.epiphantastic.com/cfjson/

Comments

0

Instead of using the CF ListToArray function, use the Java String methods to split the string into an array. This will maintain the empty list items.

<cfset jsList = "item1,item2,,item4,item5,,item6">
<cfset jsArray = jsList.split(",")>
<cfdump var="#jsArray#">

Comments

0

you are using array in JavaScript,Fine. instead of assigning by default empty value,assign some dummy value. whenever you use this array value ignore dummy value using condition.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.