0

I am adding value using JavaScript dynamically. my code is following:

<script type="text/javascript">
var i = 1;
    function add_coll() {
        var city_value = document.getElementById("city_service").value;
        if(city_value != "city")
        {
        $('#colnew').append('<div id="businesshour'+i+'" class="row"><div class= "large-4 medium-4 columns">'+city_value+'</div><div class= "large-3 medium-3 columns end"><a href="javascript:void(0);" onclick="remove_coll('+i+');" ><img src="../img/cross_icon.png"></a></div></div>');
        i++;     
}  
     }
     function remove_coll(val) {
       $('#businesshour'+val).remove();
     }
    </script>
<select id="city_service" name="city_service">
             <option value="city">Choose One</option>
             <option value="Jaipur">Jaipur</option>
             <option value="Ajmer">Ajmer</option>
             <option value="Jodhpur">Jodhpur</option>
             </select> 
          </div>
          <div class= "large-3 medium-3 columns end">
            <a href="javascript:void(0);" onClick="add_coll();" class="button city-add">+ Add</a>         
          </div>
        </div>
        <div id="colnew">

IN this code user select multiple value by clicking add button. when he select any value and enter add button this value display below select box. and user then also select new value like this.

Now how i can pass this value using ajax and save in mysql database.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
deepak
  • 1
  • 1
  • 3
  • Welcome to Stack Overflow! This question is a little short on information. Can you share what you have tried, and what problems have you run into? – Jay Blanchard Feb 09 '15 at 19:03
  • possible duplicate of [jQuery Ajax POST example with PHP](http://stackoverflow.com/questions/5004233/jquery-ajax-post-example-with-php) – Jay Blanchard Feb 09 '15 at 19:16
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). BTW, it's "Thanks in advance", not "Thanks in advanced". – John Saunders Feb 10 '15 at 03:32

1 Answers1

0

Store the city_value into array

var city_array = [];

and inside the add_col() method

city_array.push(city_value);

now you can send this array during ajax request.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Azadey
  • 11
  • 4