Hi monks,

I'm continuing to develop my website with Catalyst. I wrote a js snippet to modify html as below:

<form> <table> <tbody><tr><td><button onclick="purchase_new('new_form')">new</spa +n></button></td> </tbody></table> </form> <p id="new_form"> </p> <script language="javascript"> function purchase_new(i){ var p_new = document.getElementById(i); var new_table = document.createElement('table'); var new_th1 = document.createElement('th') var new_th2 = document.createElement('th'); var new_th3 = document.createElement('th'); var new_head1 = document.createTextNode('name'); var new_head2 = document.createTextNode('price'); var new_head3 = document.createTextNode('count'); var new_tr = document.createElement('tr'); new_th1.appendChild(new_head1); new_th2.appendChild(new_head2); new_th3.appendChild(new_head3); new_table.appendChild(new_th1); new_table.appendChild(new_th2); new_table.appendChild(new_th3); new_table.appendChild(new_tr); p_new.appendChild(new_table); } </script>
According to my predict, the page will add a new table when button clicked. But the fact is new table would flash and disappear quickly when I click button. I suspect form element result in it because it is all OK if I remove form element.

Any ideas? Thanks!

BTW, I noticed this article . And I'll apologize for my desert vocabulary if my post before made you or you uncomfortable. But I really really want to express my appreciation on the monks' help!





I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction


In reply to [OT] How avoid form submitting? by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.