I have four buttons in a form when i click each button it should direct me to its data.I have tried to write the ONCLICK dirtect to the page but nothing is happening. Do i need a script to activate that or what preferably Java
+1
A:
You can make each button change the action
attribute of the form before it submits, like this:
<form id="myform" method="GET" action="data1.html">
<input type="submit" value="Go to Data 1"
onclick="document.forms['myform'].action='data1.html'">
<input type="submit" value="Go to Data 2"
onclick="document.forms['myform'].action='data2.html'">
</form>
RichieHindle
2009-08-20 11:42:41
A:
You need script to redirect from a button yes.
It can be inline, or in a form of a function.
Inline:
<input type="submit" onclick="javascript:window.location.href='somepage.html'">
As function:
<script>
function Redirect(e, url) {
window.event.returnValue = false; //prevent event in IE
e.preventDefault(); //prevent event in FF
window.location.href = url;
}
</script>
<form>
<input type="submit" onclick="Redirect(event, 'somepage.html');">
</form>
Jabezz
2009-08-20 11:45:57
ok ,i tried this but the same thing happengs.
obusitse
2009-08-20 12:52:51
oh the toher thing that happens is that when i click a button it gives the page cannot be displayed window .I have used both
obusitse
2009-08-20 12:58:19
Your input type submit needs to be specified in a form to work. The action on the form tells the page where to post to. If you dont specify an action, it will post to itself. You can also cancel the post event. Slightly different in IE and FF.I made changes accordingly in above post.
Jabezz
2009-08-20 20:50:19
it says the object doesnt support this property9(e.preventDefault().But i used another method.the function onSubmit form.the if the document.pressed =the name of the button it will direct me to the page expected.The only problem is when click a BACK button to return to the main page,the next button on the main page doesnt go to the directed page.What might be the cause?
obusitse
2009-08-21 11:21:55