# how to submit a form  with \<a  href="javascript:" onClick="document.getElemen.......?

**URL:** <https://forum.kirupa.com/t/how-to-submit-a-form-with-a-href-javascript-onclick-document-getelemen/328605>\
**Category:** Uncategorized\
**Created:** [May 29, 2012, 4:34pm UTC](https://forum.kirupa.com/t/how-to-submit-a-form-with-a-href-javascript-onclick-document-getelemen/328605 "2012-05-29T16:34:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![multimediamkt](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@multimediamkt](https://forum.kirupa.com/u/multimediamkt)\
**Post date:** [May 29, 2012, 4:34pm UTC](https://forum.kirupa.com/t/how-to-submit-a-form-with-a-href-javascript-onclick-document-getelemen/328605/1 "2012-05-29T16:34:38Z")

</div>

\*\*[FONT=Arial]Two problems with a php mailer :

The 1st one  
• Mailer does not work with :  
\<a class=“button” href=“javascript:” onClick=“document.getElementById(‘form’).submit()”\>SUBMIT\</a\>

• It uses to work well with :  
\<input type=“Submit” name=“Submit” value=“send” class=“submitbutton”/\>

If I replace the button by the above input then it works.

However I have never used it with radiobuttons before : the form is submitted but radiobuttons are not processed which is trouble number 2 in this post;  
The script seems to be created for multi alternative checkboxes and not for selective radiobutton.

What has to be changed to accomodate both submit button and radiobuttons ?[/FONT]\*\*

> FORM

\<form class=“form-1” id=“form” method=“POST” action=“php/subscription.php”\>  
\<input type=“text” id=“name”\>  
\<input type=“text” id=“phone”\>  
\<input type=“text” id=“email”\>

\<input type=“checkbox” name=“check” value=“iwhishtoreceivemailing” \> WITH CHECKBOX VALUES ARE SUBMITTED

\<input type=“radio” name=“check[]” id=“”\> ??? don´t know how to change the code for radiobuttons

\<input type=“text” id=“message”\>

\<a class=“button” href=“javascript:” onClick=“document.getElementById(‘form’).submit()”\>SUBMIT\</a\>

how to make it work with this php script ??

MAILER.PHP (php code is pasted below)  
\<?php  
if(isset($\_POST[‘Submit’])) {  
$to = "[anything@whatever.com](mailto:anything@whatever.com) ";  
$to2 = “[johndoe@jackfrost.com](mailto:johndoe@jackfrost.com)”;  
$subject = “contact\_form”;  
$name = $\_POST[‘visitor\_name’];  
$phone = $\_POST[‘one’];  
$email = $\_POST[‘email’];  
$message = $\_POST[‘message’];

```
    foreach( (array)$_POST['check'] as $value){
$check_msg .= "Checked: $value

```

";  
}

```
    $body = "Name: $name

```

phone: $phone  
Email : $email  
Mailing: $iwhishtoreceivemailing  
Message: $message  
";

```
    header("Location: thankyoupage.html");
    mail($to, $subject, $body );
    mail($to2, $subject, $body);

```

} else {  
echo “error\_invalid\_function”;
