Welcome Guest, Not a member yet? Register   Sign In
Undesired URL after running Javascript
#11

[eluser]cinewbie81[/eluser]
Nope .. it doesnt solve the problem
#12

[eluser]coolfactor[/eluser]
Oh, I see why. You need to return false from the EditExecute() function because the form is being submitted as well. That is what is causing the problem. Returning false should prevent the form from being submitted.
#13

[eluser]coolfactor[/eluser]
If you want the form to be submitted with your revised URL, then you need to assign an ID to the form, adjust its action parameter, then submit it.

Example:

Code:
<?php echo form_open(array('name' => 'customer/action', 'id' => 'frmCustomerAction')); ?>
    <input type="image" name="edit" onclick="ExecuteEdit()" src="<?php echo base_url();?>images/edit.gif" value="Edit">
<?php echo form_close(); ?>

And then your java.script:
Code:
function EditExecute() {
    var frm = document.getElementById('frmCustomerAction');
    frm.action = mywebsiteurl + "customer/action" +"?d="+editKey+"&sid;="+Math.random();
}

That should give you the effect you want. That's not the only approach to use, but I'd need more information about your application before I could narrow in on the best approach. Another way, for example, is to capture the "onsubmit" event on the form tag itself and then have the action adjusted there.

By the way, this post belongs in the Code and Application Development forum, not the CodeIgniter Discussion forum. It's sometimes difficult to distinguish the two, but this is not a CodeIgniter question, but rather a Javascript/HTML question.




Theme © iAndrew 2016 - Forum software by © MyBB