Page 1 of 2
onclick is not working
Posted: Sun Dec 04, 2005 8:06 pm
by joecrack
i want to forward the browser with this script when clicking on a button.
the button is also a sumbit buttn for data that will be sent to sql.
I dont want to open a popup, just forward the window.
Code: Select all
<script type="text/javascript" language="javascript">
function click ()
{
location.href = "www.web.de";
}
</script>
Code: Select all
<input name="button" type="submit" value="update" onklick="click()">
So how do i make it work??
Posted: Sun Dec 04, 2005 8:08 pm
by John Cartwright
onClick not onKlick
Posted: Sun Dec 04, 2005 8:12 pm
by joecrack
uuups -

sorry
but still i does not work!!!
Posted: Sun Dec 04, 2005 8:30 pm
by neophyte
Worked for me when I added a semicolon to the input tag's on click...
onclick="click();"
Posted: Sun Dec 04, 2005 8:48 pm
by joecrack
doesnt work!!!
if the one semicolon was the only thing that you changed, then it has to be something with my browser ???
or could it be tat it is sometingwith the button, that you cankt have submit an onclick or whatever ???
just to be sure:
Code: Select all
<script type="text/javascript" language="javascript">
function click() {
location.href = "www.web.de";
}
</script>
Code: Select all
<input name="knopf" type="submit" value="update" onclick="click();">
Posted: Sun Dec 04, 2005 8:53 pm
by neophyte
Code: Select all
<html>
<head>
<script type="text/javascript" language="javascript">
function myClick ()
{
location.href = "http://www.yahoo.com";
}
</script>
</head>
<body>
<input name="button" type="button" value="update" onclick="myClick();">
</body>
</html>
Just did this in FF; worked.
Posted: Sun Dec 04, 2005 9:02 pm
by joecrack
so the problem is the type=""
when it put in type="button" it is working - with sumbit its not.
but it as to be a submit button, cause it has to sent the data to sql.
Posted: Sun Dec 04, 2005 9:10 pm
by neophyte
So in your form tag add a onsubmit="myClick();"
But that begs the question, why are you using a JS redirect when you can just use your form action attribute?
Posted: Sun Dec 04, 2005 9:20 pm
by joecrack
the onsubmit is not working.
how would a action tag lok like???
Posted: Sun Dec 04, 2005 9:28 pm
by neophyte
Code: Select all
<form name="myform" action="mypage.php" method="post">
<input type="submit" name="submit" value="submit">
</form>
Posted: Sun Dec 04, 2005 9:51 pm
by joecrack
okey - now its opening a new site .. but the submit is not working anymore ...
Posted: Mon Dec 05, 2005 6:19 am
by Chris Corbyn
Please post your full code... we're all just guessing here
I can't see any reason why it wont work based on what you posted.... you're sure JS isn't disabled in your browser?
What does this do (just a test);
Code: Select all
<script type="text/javascript">
<!--
alert('JS is working Fine and Dandy!');
// -->
</script>
<noscript>
Sorry but JS isn't turned on
</noscript>
Posted: Mon Dec 05, 2005 11:32 pm
by joecrack
@d11wtq
It tells me that JS working fine!!!
The code is too long - its like 3pages, because it a huge php code.
I hope ifi post this part its enough:
Code: Select all
<br><br>
Which Order you want to update?<br>
<br>
<table width="504">
<form action="back.htm" method="post">
<tr>
<td width="167"><div align="right">Type the Projekt Number:</div></td>
<td width="325"><input name="projnr" type="text" id="projnr" length="3">
(cant be changed) </td>
</tr>
<tr>
<td><div align="right">Customer Number:</div></td>
<td><input name="customernr" type="text" id="customernr" length="3">
(cant be changed) </td>
</tr>
<tr>
<td><div align="right">Contract Date:</div></td>
<td><input name="contrdate" type="text" id="contrdate" length="3">
(cant be changed)</td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<input name="knopf" type="submit" value="update">
</div></td>
</tr>
</form>
</table>
Posted: Mon Dec 05, 2005 11:43 pm
by Burrito
joecrack wrote:okey - now its opening a new site .. but the submit is not working anymore ...
what do you mean it's opening a new site? You mean it's taking you to the action page (which btw is a .htm page)?
that's what it's supposed to do...what exactly do you want this to do?
Posted: Tue Dec 06, 2005 12:31 am
by joecrack
i mean now it is moving to the next url but .. the submit to the sql database does not work anymore^^
it is htm page yeah