PHP Javascript how to change value of user form, but value has multidata -


i want ask how change value of input in form, has multiple data inside value.

my form :

<form method="post" action="pax-flight.php#pax-flight" class="paxform">     <input type="hidden" value="{"data":{"user_agent":"sometravel","user_pass":"sometravel","additional":"99507","depart":"sub","destiny":"cgk","date":"20-06-2015","date2":null,"adult":"1","child":"0","infant":"0"},"0":{"airlines_code":"id 6401","airlines_name":"lion","airlines_class":"economy","airlines_seat":1,"airlines_price":"685000","airlines_nta":664450,"airlines_depart":"05:30","airlines_depart_fr":"sub","airlines_arrive":"07:00","airlines_arrive_to":"cgk","airlines_international":2}}"            name="data">      <div class="search">          <input class="searchbtn" type="submit" value="next »">     </div>     <br> </form> 

and how can change data value, example want change date only, or want change airlines_class only. possible?

*without refreshing pages, js can change data, right? how change 1 data inside of value?

see problem if binding json data using code need use json.stringify bind it. in case value of input {, why not able access data want. suppose bound,

<script>   var obj={"data":{"user_agent":"sometravel","user_pass":"sometravel","additional":"99507","depart":"sub","destiny":"cgk","date":"20-06-2015","date2":null,"adult":"1","child":"0","infant":"0"},"0":{"airlines_code":"id 6401","airlines_name":"lion","airlines_class":"economy","airlines_seat":1,"airlines_price":"685000","airlines_nta":664450,"airlines_depart":"05:30","airlines_depart_fr":"sub","airlines_arrive":"07:00","airlines_arrive_to":"cgk","airlines_international":2}};  window.onload=function(){  var input=document.getelementsbytagname('input'); (var = 0; < input.length; i++) {     if (input[i].type=='hidden') {         input[i].value=json.stringify(obj).replace(/"/g,'\\"');     }        }  }; </script> 

in way input has object assigned value. if want retrieve of data can do

  var input=document.getelementsbytagname('input')[0].value;   //assuming input tag first tag in html content   var retrive=json.parse(input); 

now have object in retrive variable. can continue modfication , re-assign hidden input tag.

fetch

example below:

function modifydata() {    var input =document.getelementsbytagname('input');    (var = 0; < input.length; i++) {     if (input[i].type=='hidden') {         var retrieve=json.parse(input[i].value.replace(/\\"/g,'"'));         //got original object         //now can access objects follows         retrieve.data.user_pass="lotoftravel";//initial value - sometravel         //after modifying data putting value of input tag         input[i].value=json.stringify(retrieve).replace(/"/g,'\\"');     }        } } 

this should it.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -