10 Lis 2017

Odczyt atrybutów elementu w obsłudze zdarzena w javascript

<select name="banner_url" onchange="var idx=this.selectedIndex;
var value=this.options[idx].getAttribute('banner_url');
var element = document.getElementById('img_banner_url');
element.setAttribute('src', value); element.style.display='block'">


!{section name=ii loop=$data}!
  !{capture assign=banner_url}!http://kody.wig.pl/!{/capture}!
  <option value="!{$banner_url}!" banner_url="!{$banner_url}!">
  !{$data[ii].name}! ---> !{$banner_url}!</option>
!{/section}!

</select>
<br><br>

<img src="" id="img_banner_url" style="display:none">
28 Lis 2010

Dodanie atrybutu do diva

let div = document.createElement('div');
div.className = 'box';
div.id='test';
div.innerHTML = '[<a href="http://mapy.emiejsca.pl/niedrzwica_duza_niedrzwica_duza_lubelski_lubelskie,mapa.html">Niedrzwica Duża</a>]';
div.setAttribute('index', 100);
6 Paź 2008

Utworzenie najprostszego dokumentu XML

$docs = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$pages = $docs->appendChild(new DOMElement('pages'));
$element_page = $pages->appendChild(new DOMElement('page'));
$element_page->setAttribute("id", "123456");
$element_name = $docs->createElement('link', 'link numer 123456');
$element_page->appendChild($element_name);
$element_CDATA = $docs->createCDATASection('http://kody.wig.pl/');
$element_url = $element_page->appendChild(new DOMElement('url'));
$element_url->appendChild($element_CDATA);
$xmldata = $docs->saveXML();
echo $xmldata;