Jump to content

LittleSmilingMonster

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

LittleSmilingMonster's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello there!!! I am having a problem in my java script!! I have made a javascript in order for the user to dynamically generate fields in a form of my site and i want to put a Delete button in every one of them so they can be deleted if not needed afterwards. But i dont know how to do the script. my script is this one function add_feed() { var div1 = document.createElement('div'); div1.innerHTML = document.getElementById('attr').innerHTML; document.getElementById('Attributes').appendChild(div1); } and the form is this one <div id='category'> <form name="Create Category" align="center" action="Assets/register_test.php" method="post"> <table style="margin-left: 38%;" id="Category"> <tr> <h1 align="center">Create Category</h1> </tr> <tr align="right"> <td> Name: </td> <td> <input style="margin-top: 3px;" type="text" name="username" size="30"> </td> </tr> <tr align="right"> <td>owner: </td> <td> <input style="margin-top: 3px;" type="password" name="password" size="30" > </td> </tr> </table> <tr> <h2 align="center">Attributes</h2> </tr> <table style="margin-left: 40%;" id="Attributes"> <tr class="feed" align="left"> <td> <input style="margin-top: 3px;" type="text" name="Attribute" id ="Attribute" size="30"> <br/> <form align="center"> <input type="radio" name="value" value="measurable" /> measurable <input type="radio" name="value" value="unmeasurable" /> unmeasurable </form> </td> </tr> </table> <div id="attr" style="display:none"> <div class="feed" id="feed"> <input type="text" name="Attribute" id ="Attribute" value="" size="30"> <form> <input type="radio" name="value" value="measurable" /> measurable <input type="radio" name="value" value="unmeasurable" /> unmeasurable <a style="height: 25px; margin-left:48%; margin-top: 20px;" href="javascript:de_feed()">Delete </a> </form> </div> </div> <a style="height: 25px; margin-left:48%; margin-top: 20px;" href="javascript:add_feed()">Add New </a> <input style="height: 25px; margin-left:48%; margin-top: 20px;" type="submit" value="Submit" onclick="validateFields()"> <input style="height: 25px; margin-left:48%; margin-top: 20px;" type="reset" value="Reset"> <br/> </form> </div>
  2. Hello there!!! I am taking my first steps into php and html code and i am facing a problem. I am making a form in order for the user to create a new category in my page but i don't know how many Attributes the category will have. So i made a field for the Attribute followed by a radio tha chooses if the Attribute is measurable or unmeasurable. After that I have set a Button in order to regenerate it with JavaScript as many times as necessary. this is the html code: <form name="Create Category" align="center" action="Assets/register_test.php" method="post"> <table style="margin-left: 40%;" id="Attributes"> <tr> <h2 align="center">Attributes</h2> </tr> <tr class="feed" align="left"> <td> <input style="margin-top: 3px;" type="text" name="Attribute" size="30"> <br/> <form align="center"> <input type="radio" name="var" value="measurable" /> measurable <input type="radio" name="var" value="unmeasurable" /> unmeasurable </form> </td> </tr> </table> <div id="attr" style="display:none"> <div class="feed"> <input type="text" name="Attribute[]" value="" size="30"> <form> <input type="radio" name="var" value="measurable" /> measurable <input type="radio" name="var" value="unmeasurable" /> unmeasurable </form> </div> </div> <a style="height: 25px; margin-left:48%; margin-top: 20px;" href="javascript:add_feed()">Add New </a> <input style="height: 25px; margin-left:48%; margin-top: 20px;" type="submit" value="Submit" onclick="validateFields()"> <input style="height: 25px; margin-left:48%; margin-top: 20px;" type="reset" value="Reset"> <br/> </form> this is my JavaScript: function add_feed() { var div1 = document.createElement('div'); // Get template data div1.innerHTML = document.getElementById('attr').innerHTML; // append to our form, so that template data //become part of form document.getElementById('Attributes').appendChild(div1); } The problem is the Reset button. When i hit the Reset button everything gets erased in all the text-inputs But the radios (except the first one) don't. Is there is anyone who can help please?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.