The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Losing it after days on trying to figure this out, turn button into link
eabigelow
post Aug 25 2011, 05:41 PM
Post #1


Newbie
*

Group: Members
Posts: 13
Joined: 24-August 11
Member No.: 15,242



Hi--

I have this button in a HTML/PHP contact form:

<input type="submit" value="Submit" />

Preceded by this script in the Head:

<script type="text/javascript">
$(function(){
$('#contact-form').submit(function(e){
e.preventDefault();
var form = $(this);
var post_url = form.attr('action');
var post_data = form.serialize();
$('#loader', form).html('<img src="loader.gif" /> Please Wait...');
$.ajax({
type: 'POST',
url: post_url,
data: post_data,
success: function(msg) {
$(form).fadeOut(500, function(){
form.html(msg).fadeIn();
});
}
});
});
});
</script>

That combination works to submit the contact form using a php file called process.php.

The problem is, I'd like to make that button into a LINK that does the exact same thing (my site doesn't want a button there).


I have tried a javascript link, like so:

function submitform()
{
document.forms["contact-form"].submit();
}
</script>

Followed by the js link:

<a href="java script: submitform()">Submit This</a>

BUT this does not work to submit the form as the button does.

Is there any way to do this?

Many thanks for any help! I am ready to tear my hair out...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 26 2011, 01:48 AM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,884
Joined: 9-August 06
Member No.: 6



A better approach is to style the input button so it looks like a link (if you must).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
eabigelow
post Aug 27 2011, 11:27 PM
Post #3


Newbie
*

Group: Members
Posts: 13
Joined: 24-August 11
Member No.: 15,242



Problem resolved. Thanks!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 7th July 2020 - 06:17 PM