Hello! Help please understand, I do not understand how to implement it.

There are for example 4 fields on the site when editing the material. The address of the page is: http://site.ru/edit?url=site.ru/doc1&title=Тут+назваие+статьи&description=Описание&user=Admin

How from the address bar to expand all the fields?

title - in the field with id "title"

url - in the field with id "url", etc.

There is such code:

 <script type="text/javascript"> $(document).ready(function () { if(location.search) { var title = location.search.toString(); $('input').val(decodeURIComponent(title.split('?title=').join(''))); } } ); </script> 
  • The code in the studio ... - edem
  • corrected the question - meucoz

1 answer 1

 <?php $string = 'http://site.ru/edit?url=site.ru/doc1&title=Тут+назваие+статьи&description=Описание&user=Admin'; $query = explode('?',$string); if(!array_key_exists(1,$query)){ die('Params no found.'); } $query = $query[1]; $params = array(); $attrs = explode('&',$query); foreach($attrs as $attr){ $a = explode('=',$attr); if(array_key_exists(1,$a)){ $params[$a[0]] = $a[1]; }else{ $params[$a[0]] = null; } } var_dump($params); 
  • Thank you very much. only I, stupid, forgot to point out, what on jquery or js is it possible? - meucoz