javascript - Passing table as hidden value in html form - weird single/double quote issue -


i have php function outputs form button (with post) download pdf of table on previous page. reason, weird results if try use double quotes, single quotes in string declaration work ok (except when try feed butter js innerhtml).

this works:

$form = '<form action="../php/pdf_and_die.php" method="post" target="_blank">'; $form .= '<input type="hidden" name="table" value="'.$table.'">'; // more lines here $form .= '<input type="hidden" name="page" value="portrait">'; $form .= '<input type="submit" value="     '.$button_name.'     " class="button"></form>'; 

but doesn't:

$form = "<form action='../php/pdf_and_die.php' method='post' target='_blank'>"; $form .= "<input type='hidden' name='table' value='{$table}'>"; // more lines here $form .= "<input type='submit' value='{$button_name}     ' class='button'></form>"; 

when try second way double quotes, table displayed before button. screenshot double quotes

shouldn't single/double quotes same far php , html concerned, long they're used consistently? (barring differences variables in strings "foo{$bar}").

this wouldn't problem , go working single quotes string declaration inside php function, except on page, have pulldown menu onclick , js function replaces 1 of these buttons based on academic session user chooses, , innerhtml doesn't seem single quote (double quotes inside) option. screenshots

on page displays button: (abbreviated readability)

<?php     foreach ($sessions $session) {         // string of attendance table         $session_table = get_class_attn_table($course, $acad_year, $session);          // get_pdf_form_button returns string         $attn_button = get_pdf_form_button($session_table);          // add output html array string         $sessions_text[] = $attn_button;     } ?> <script type="text/javascript">     function toggle_session() {         var x = "" + document.getelementbyid("session_select").value;         var session1_text = "<?php echo $sessions_text[0];?>";         var session2_text = "<?php echo $sessions_text[1];?>";          if (x == "1") {             document.getelementbyid("change_session").innerhtml = session1_text;         }         else if (x == "2") {             document.getelementbyid("change_session").innerhtml = session2_text;         }     } </script>  <select id="session_select" onchange="toggle_session()">     <option selected value="">select...</option>     <option value="1">1</option>     <option value="2">2</option> </select>  

i'm pretty new php , js, maybe missed simple.

as had been worked out in comments, $table variable did have quotes in it, messed html.

solutions problematic quotes:


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -