send button in HTML

  • Thread starter Eldert Besseling
  • Start date
E

Eldert Besseling

Hi,

I have a problem with my HTML code in combination with javascript
hereby the code:

<!-----------------------------------------------
<html>
<head>
<base target=hoofdscherm>
<link rel='stylesheet' type='text/css' href='stldata.css'>
<SCRIPT LANGUAGE='javascript'>

function check(f)
{
alert("jaja");
}

</SCRIPT>
<form method='GET' action='data00.bgi' name='f2'>
</head>
<table border='0' cellpadding='0' cellspacing='0' width=100%>
<tr>
<td> pagina <input type='text' size=10 maxlength='4' name=pagtable
value=10> van 20
<p><input type="submit" value="Verzenden" name="B3"
onclick="javascript:return check(f1)"></p>
</form>
</td>

<!-- <td width=0 height=0 colspan="2"><input type='text' size=0></td> -->

</tr>
</table>
</form>
</html>


------------------------------------------------>

When i change the value in the input box following by a carriage return the
GET action is taken but the javascript from the submit button is not
running.
When activate the: <!-- <td width=0 height=0 colspan="2"><input type='text'
size=0></td> --> line and type carriage return the javascript is running!

The javascript must always run to check the input.

Can you help me?

Regards,

Eldert
 
S

Steve Pugh

Eldert Besseling said:
I have a problem with my HTML code in combination with javascript
hereby the code:
<form method='GET' action='data00.bgi' name='f2'>
</head>

Um. Those lines have to be the other way round.
<table border='0' cellpadding='0' cellspacing='0' width=100%>
<tr>
<td> pagina <input type='text' size=10 maxlength='4' name=pagtable
value=10> van 20
<p><input type="submit" value="Verzenden" name="B3"
onclick="javascript:return check(f1)"></p>
</form>

That said:
</td>

<!-- <td width=0 height=0 colspan="2"><input type='text' size=0></td> -->

</tr>
</table>
</form>
</html>

When i change the value in the input box following by a carriage return the
GET action is taken but the javascript from the submit button is not
running.

Of course. The JavaScript is only triggered when the button is
clicked. You used onClick so that's exactly what happens.
When activate the: <!-- <td width=0 height=0 colspan="2"><input type='text'
size=0></td> --> line and type carriage return the javascript is running!

For some browsers, maybe.
The javascript must always run to check the input.

What if the user doesn't have JavaScript enabled?
Always check on input on the server to be sure. Then add an extra
check very JavaScript on the client side to save time (any with JS
enabled will get the error message straight away rather than waiting
for a round trip to the server) and bandwidth.

To trigger a JavaScript when the form is submitted use the onSubmit
handler on the form tag, not the onClick handler on a button.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,605
Members
47,225
Latest member
DarrinWhit

Latest Threads

Top