I have a problem. I want to have an reset/clear button in my form, but it won''t work..


Line 1-8 is the php for my form on line 94-97

  <form id="myForm" method="post" action="" onSubmit="if(!confirm('Är du säker på att du vill acceptera budet?')){return false;}">
   <input type='text' value="1" value='<?php echo $doors ?>' name='doors[<?php echo $auto->ID; ?>]'>
   <input type="button" onclick="" value="Neka bud"> - <input type='submit' value='Godkänn bud' />

if ( isset( $_POST['doors'] ) ){  
// verify nounce prob a good idea
    foreach($_POST['doors'] as $item=>$key) {
        $id= sanitize_text_field($item);
        update_post_meta( $id, 'doors', sanitize_text_field( $key ) );

Any suggestions to what the problem might be :)


If you want to have a reset button you have to include a reset input in the form:

<input type="reset" value="Reset!">

This element resets all form values to default values.

In your example

<input type="button" onclick="" value="Neka bud"> - <input type='submit' value='Godkänn bud' />
<input type="reset" value="Reset!">
  • 1
    yes but i want to reset the default value, my default value is "1" and yes i know that i can use placeholder but thats not an option :) – user2062819 Aug 4 '14 at 18:39
  • Then you have to reset the values using Javascript. – amieiro Aug 4 '14 at 18:46
  • first I'll tell you that code of text field is wrong. you can't add 2 values in one field. value="1" value='<?php echo $doors ?>' should be value="1" or value='<?php echo $doors ?>' – Chinmoy Kumar Paul Aug 4 '14 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.