November 26, 2010

Problem with form submission

Question by shalu

I am facing a problem. I am having a form. Its action is ac.php. I want to change the action to sit.php.

For this what i did

   <script type="text/javascript">
     document.getElementById("digForm").innerHTML="<form enctype='multipart/form-data' id='product_addtocart_form' method='post' action='http://localhost/bracelatest2/index.php/checkout/cart/add/uenc/aHR0cDovL2xvY2FsaG9zdC9icmFjZWxhdGVzdDIvaW5kZXgucGhwL2JsYWNrLWJyYWNlLmh0bWw_X19fU0lEPVU,/product/203/'>";
   </script>

<div id="digForm">
    <form action="ac.php">
</div>

Now I am using ajax and changing the inner html of div myform by

    <form action="sit.php">

But when i hit submit form is going to ac.php not to sit.php.

Please help me.

Answer by Starx

If you just want to change the attribute then use

document.getElementById('myform').action = 'sit.php';

Check the demo here Shalu http://jsfiddle.net/bR2KA/

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!