JavaScript Change form_open path (CodeIgniter)

I have a simple form here,

<?php echo form_open('moneyexchange/invest_first_page');  ?>
     <input id="amount" value="" type="text" placeholder="Amount in &euro;"  name="writtenamount"/>
     <button class="btn btn-lg" type="submit" id="yourbuttonid" >Invest</button> 
     <button class="btn btn-lg" type="submit" id="yourbuttonid2">Borrow</button>
<?php echo form_close();?>

What I want to do is on submit of each button, I want to change the path of the form, if I press submit on Invest button, it goes to this path moneyexchange/invest_first_page , and I need it to change paths when I click the Borrow button, since I am using one input field for both. Right now it works only when I click invest. Do tell me in details steps please.

Answer:1

You can use jquery and do this.

<script type="text/javascript">
    $('#yourbuttonid').click(function() { 
        $.ajax({
            url: 'moneyexchange/invest_first_page',
            method: 'POST',
            data: { writtenamount: $("#amount").val()},
            success: function (result) {
              // do stuff
            }
        });  
    });
</script>

Do the same for the other button, but in your script just change the id to yourbuttonid2

Answer:2

I have two sortables connected by means of jQuery sortable plugin. Is it possible to change target for draggables for one of them? I want to drag not from #sortable1 to #sortable2, but to $('#sortable'...

I have two sortables connected by means of jQuery sortable plugin. Is it possible to change target for draggables for one of them? I want to drag not from #sortable1 to #sortable2, but to $('#sortable'...

  1. jquery sortable connected lists
  2. jquery sortable connectwith
  3. jquery connectedsortable refresh
  4. jquery ui sortable connected lists
  5. jquery sortable connectwith multiple
  6. jquery ui connect sortable with droppable
  7. jquery ui connected sortable
  8. jquery ui connectedsortable style

I am creating an application in django and I have the next problem. I have some search forms in the application, and in some of them there are fields of type 'DateField'. In addition, I have ...

I am creating an application in django and I have the next problem. I have some search forms in the application, and in some of them there are fields of type 'DateField'. In addition, I have ...

I want to transform following format JSON: { id1: value1, id2: value2 id3: value3, ... } into [ { id: 'id1', value: 'value1' }, { id: 'id2', value: 'value2' }, { ...

I want to transform following format JSON: { id1: value1, id2: value2 id3: value3, ... } into [ { id: 'id1', value: 'value1' }, { id: 'id2', value: 'value2' }, { ...

  1. transform json key value
  2. transform json key

I have added few elements with "visibility:hidden; position:fixed;" to the top of the page and for some reason, when I launch the script in Chrome, it makes "#pageOverlay" visible, but fails to unhide ...

I have added few elements with "visibility:hidden; position:fixed;" to the top of the page and for some reason, when I launch the script in Chrome, it makes "#pageOverlay" visible, but fails to unhide ...