0

i am totally new to coding. So seeking for help in having ONLY checkboxes ‘checked’ for ‘unable to find character’ echo. I suspect its some if/else kind of statement, but after several times of trial and error, I ended up have all checkboxes checked (which is not correct). Very lost…So I am reaching out to experts here for your kind guidance. Attached what I suspect as relevant original lines below for any expert’s advice, thank you very much:

echo '<tr>';
    echo '<th valign="top" class="label" scope="row">';
    echo '<input type="checkbox" class="chkLink alignleft">';
    echo '<span class="alignleft"><label for="cartoon">';
    _e('Source URL', 'cartoon');
    echo '</label></span>';
    echo '<span class="alignright"><abbr class="required" title="required">*</abbr></span>';
    echo '</th>';

function cartoon_we_fetch_names_callback() {
$url = CARTOON_EMBED_IMP_UTILITIES::globalRequest('cartoon_we_url');

$html = cartoon_file_get_html($url);

if(!$html) {
    echo '<div class="error notice-error notice-alt">Unable to find Character</div>';
    wp_die();
}


$names = $html->find('#names > ul', 0);

if(!$names) {
    echo '<div class="error notice-error notice-alt">Unable to find Character</div>';
    wp_die();
}

foreach ($names->find('.namesnumber') as $e) {
    $e->outertext = '<input type="checkbox">' . $e->outertext;
}

foreach($names->find('a') as $link){
    if($link->href) {
        $id = split('#', $link->href);
        $id = $id[1];
        $link->href = 'javascript:void(0);';
        $link->outertext = $link->innertext;
        $link->dataTarget = $id;
        $link->parent()->datatarget = $id;
    }
}
J. Chomel
  • 8,193
  • 15
  • 41
  • 69
Aaron.T
  • 9
  • 2

1 Answers1

1

You can just use the checked attribute:

echo '<input type="checkbox" class="chkLink alignleft" checked>';
MrDarkLynx
  • 686
  • 1
  • 9
  • 15
  • Thanks alot @MrDarkLynx . i have slightly changed my question, hopefully you can have a look and comment too. thanks. – Aaron.T Mar 10 '17 at 07:18
  • @Aaron.T _slightly changed_ might be a little understated. You should ask a new question instead. – MrDarkLynx Mar 10 '17 at 07:25