Click to See Complete Forum and Search --> : simple problem / accomplish a method of an form objekt


Warli
05-12-2003, 05:31 AM
Hello,

i have a simply question...

I would like to send a value from a HIDDEN Field to another side.

with HTML...:

->form.html
<form name="form1" method="post" action="form1.php">
<input TYPE="hidden" value="TEST" name="TEST">
<input TYPE="submit">
</form>


->form1.php
<?
echo $TEST;
?>


...thats easy

my question:
for the submit button I would indicate a text (no TYPE="text")
how accomplish the action?



my source:

<script type="text/javascript">
<!--
function go()
{
document.form1.submit();
}
//-->
</script>

<form name="form1" method="post" action="form1.php">
<input TYPE="hidden" value="TEST" name="TEST">
<a href="#" onClick="Go()">TEST</a>
</form>
?>

I hope anybody helps me... thanks a lot
warli

Gollum
05-12-2003, 05:54 AM
the bits you are missing are:
- the href should be "javascript:void 0;" so that the link has nowhere to go.
- the onclick should return false so that processing is stopped.

so...

<a href="javascript:void 0;" onclick="document.form1.submit(); return false;">Go There!</a>

Warli
05-12-2003, 06:07 AM
Oh **** .)
Thanks a lot.. you helped me well.
im cut capers.. thanks!!

warli

Charles
05-12-2003, 06:16 AM
Originally posted by Gollum
<a href="javascript:void 0;" onclick="document.form1.submit(); return false;">Go There!</a> Is very, very bad. It will fail on the one in ten users that do not use JavaScript. And people with certain disabilities cannot use JavaScript. Use instead:

<input type="submit" value="Some Text">

or

<script type="text/javascript">
<!--
document.write{'<a href="">Some Text</a>');
document.links[document.links.length-1].onclick = function () {document.forms.form1.submit(); return false};
// -->
</script>
<noscript><input type="submit" value="Some Text"></noscript>

Warli
05-12-2003, 08:24 AM
stupid question...

<a href="javascript:void 0;" onclick="document.Form.submit(); return false;">

onclick the document should be in another target...
Javascript is not my world :)

so after the click, in target="content" should be the form1.php

Thanks again
warli