I am trying to do the following, i hope someone will be able to help me out. I have one form with one input text field. I want to be able to take that input and break it off. For example : user inputs "word1 word2" I want to have that passed to the second page as "word1_word2". Any idea how i can do this? i dont need that info saved on my db, but i will if it simplifies things. Thanks a lot in advance, you guys never disappoint!
If you want to change the value before the form is submitted (ie in the client browser) that means using javascript. Just use the replace() method to replace spaces with an underscore "_" character. http://www.w3schools.com/jsref/jsref_replace.asp BUT, javascript can be disabled. So it is usually better to do that kind of processing on the server with CF code. So .. is there any reason you cannot just pass "word1 word2" and do the string handling on the action page?
Nope, i can do it on the action page, i just don't know how. They link you provided uses java; i know how to do it with java, but i didn't want to; just wanna use CF
I think it is best if you explain what you want tp do with the input. Is it always two words? Do you want to insert the words separately in the database or shall it be the complete phrase/set of words with some modification? If you want to split them, separate the words, the List functions is easiest. word_1 = listFirst(myInput,' '); word_2 = listLast(myInput,' '); or, of it is many words, maybe you want to create an array aWords = listToArray(myInput,' '); Note that the delimiter used is space (' '). But I think that before you can get a good answer, you need to give us a good question
ok that helps a bit : Ill try to clarify my question. I have a search input box in a form. I want to pass that through to the action page as is. For example some one will input in that search box "what is the best dog breed". I want that to pass that through to my action page as "what is the best dog breed", but i also want a variable to equal "what+is+the+best+dog+breed" and "what_is_the_best_dog_breed" as well as "what is the best dog breed". I will use these two variables in the action action page, so as mentioned earlier, i do not need it saved on a db. However, i do not mind using a database and storing each word separate if it makes this task a whole lot easier. Thnx
While I don't understand what you are doing with these values, it seems like you want to replace a space character with something else. So have you looked at the replace() function in the documentation? http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions-pt0_02.html <cfset newValue1 = Replace(yourFormField, " ", "+", "all")> <cfset newValue2 = Replace(yourFormField, " ", "_", "all")>