Прежде всего, вам нужно очистить
<input type="button" value="Preview" id="preview" name="preview" id="preview" class="preview" />
до:
<input type="button" value="Preview" id="preview" name="preview" />
, так как вход не должен иметь несколько атрибутов id, и вы не должны использовать классы и идентификаторы содно и то же имяЭто может быть одной из причин, почему у вас проблемы.Затем я использовал следующий код, и URL-адрес действия фактически изменился:
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#preview").bind("click", changeForm);
function changeForm(event){
alert("Before: "+ $("#franchiseform").attr("action"));
$("#franchiseform").attr("action", "franchisepreview.php");
alert("After: "+ $("#franchiseform").attr("action"));
$("#franchiseform").submit();
}
});
</script>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="franchiseinsert.php" class="insert-new" id="franchiseform">
<input type="button" value="Preview" id="preview" name="preview" />
<input type="submit" value="Insert" />
</form>
</body>
</html>