Pętla nie wykonuje się dla elementów ukrytych, które są pomiędzy znacznikami <div id="sub1" style="display: none;"></div>. Element $row['e_www'] wyświetla się prawidłowo. Zależy mi na tym aby pobrać dane z bazy następnie wyświetlić je w formie rozwijanych linków do formularzy.
Przed kliknięciem formularz wygląda tak:
przed kliknięciempo kliknięciu się rozwija i wygląda tak:
przed kliknięciem$sql = "SELECT * FROM strony LIMIT ".$start.",".($end - $start + 5);
echo '<p>Edycja stron: </p>';
echo html_input
('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '','<a onclick="toggle(\'sub1\')" style="cursor: pointer;">'.$row['e_www'].'</a>'); echo '<div id="sub1" style="display: none;">'; echo html_input
('form', '', '', '', '', '', '', '', '', '', '', '', 'post', SITE
.'admin.php?action=dodaj&task=edit_settings', ''); echo html_input
('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '','Aktualizacja strony'); echo html_input
('text', 'tytul_name', 'tytul_id', $row['e_title'], 'Tytuł strony', '', '', '', '', '', '', '', '', '', ''); echo html_input
('text', 'adres_name', 'adres_id', $row['e_www'], 'Adres strony', '', 'onkeypress="return SEFrestrict(event);"', '', '', '', '', '', '', '', ''); echo html_input
('textarea', 'description_name', 'description_id', $row['e_desc'], 'Domyślny opis znacznika META (dla wyszukiwarek)', '', '', '', '', '', '2', '100', '', '', ''); echo html_input
('text', 'keywords_name', 'keywords_id', $row['e_keywords'], 'Domyślne słowa kluczowe znacznika META (oddzielone przecinkiem)', '', '', '', '', '', '', '', '', '', ''); echo html_input
('hidden', 'id_name', 'id_id', $row['id'], '', '', '', '', '', '', '', '', '', '', ''); echo html_input
('submit', 'submit', 'submit_id', 'Zaktualizuj stronę', '', 'button', '', '', '', '', '', '', '', '', ''); echo html_input
('submit', 'delete_site', 'delete_iste', 'Skasuj stronę', '', 'button', 'onclick="java script: return pop()"', '', '', '', '', '', '', '', ''); echo '</fieldset></div></form></fieldset>'; }
//Funkcja tworząca formularz i jego elementy
function html_input($type, $name, $id, $value, $label, $css, $script1, $script2, $script3, $checked, $rows, $cols, $method, $action, $legend) {
$lbl = !empty($label) ?
'<label for="'.$id.'">'.$label.'</label>' : ''; $ID = !empty($id) ?
' id="'.$id.'"' : ''; $style = !empty($css) ?
' class="'.$css.'"' : ''; $js1 = !empty($script1) ?
' '.$script1 : ''; $js2 = !empty($script2) ?
' '.$script2 : ''; $js3 = !empty($script3) ?
' '.$script3 : ''; $attribs = $ID.$style.$js1.$js2.$js3;
$val = ' value="'.$value.'"';
$input = '<input type="'.$type.'" name="'.$name.'"'.$attribs;
switch($type) {
case 'form': $output = (!empty($method) && $method != 'end') ?
'<form method="'.$method.'" action="'.$action.'"'.$attribs.' accept-charset="'.s('charset').'">' : '</form>'; break;
case 'fieldset': $output = (!empty($legend) && $legend != 'end') ?
'<fieldset><legend'.$attribs.'>'.$legend.'</legend>' : '</fieldset>'; break;
case 'text':
case 'password': $output = '<p>'.$lbl.':<br />'.$input.$val.' /></p>'; break;
case 'checkbox':
case 'radio': $check = $checked == 'ok' ? ' checked="checked"' : ''; $output = '<p>'.$input.$check.' /> '.$lbl.'</p>'; break;
case 'hidden':
case 'submit':
case 'reset':
case 'button': $output = $input.$val.' />'; break;
case 'textarea':
$output = '<p>'.$lbl.':<br />
<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.$attribs.'>'.$value.
'</textarea></p>'; break;
}
return $output;
}
// toggle dynamic divs
function toggle(div) {
var elem = document.getElementById(div);
if (elem.style.display=='') {
elem.style.display='none';
return;
}
elem.style.display='';
}