Thursday, 15 May 2014

php - pass text box array values into javascript -


I have a hidden text box that is in the loop. (Codeigniter View File)

  & lt; Input type = "hidden" value = "& lt ;? php echo $ name- & gt; file_name ;? & gt;" Name = "high_name []" />  

I want to pass this array values ​​to my java script function. I do not know how to do this for the array.

  $ (".button"). Click (function () {var name = document.getElementById ('high_name []'). Value; alert (name);});  

What do I need, find these names and pass it in the value of another text area.

  & lt; Textarea & gt; ..... and lieutenant; / Text field & gt;  

something like that?

Note : I adjusted a little HTML. A class was added to the input and was created in place of text hidden . text is for example purposes, see what's happening. Because the class (as far as I know) does not make all the good selection of elements with array notation to all browsers.

  $ (". Button ") (function () {$ ('Val')" $ "(" # toheere "). Val (currentVal +" \ n "+ $ (This) .val ());});});  
  & lt; Script src = "https: // ajax .googleapis.com / ajax / libs / jQuery / 2.1.1 / jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Input type = "text" value = "value1" name = "high_name []" class = "high_name" /> & Lt; Input type = "text" value = "value2" name = "high_name []" class = "high_name" /> & Lt; Input type = "text" value = "value3" name = "high_name []" class = "high_name" /> & Lt; Button class = "button" & gt; Click me & lt; / Button & gt; You run  \ n   but this comes when you apply this example to your needs 


No comments:

Post a Comment