开发者

Problem with form submission

开发者 https://www.devze.com 2023-01-27 06:23 出处:网络
I am facing a problem. I am having a form. Its action is ac.php. I want to change the action to sit.php.

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 ch开发者_如何学运维anging 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.


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/


Try from

    <div id="myform">
    <form action="ac.php">

to

<div>
<form action="ac.php" id="myForm">

then use jquery to change the action of the form by doing smth like

$("#myForm").attr('action', 'sit.php');

edit

if you include jQuery library in you're header like this:

<script src="path/to/jquery.js" type="text/javascript"></script>

then use

<script type="text/javascript">
    $("#myForm").attr('action', 'sit.php');
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消