home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Javascript beginner needs help with form submissions

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1889
Discussions: 200,936, Posts: 2,379,207, Members: 246,300
Old July 29th, 2009, 11:48 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 1
Javascript beginner needs help with form submissions

I'm a beginner with Javascript, and am curently playing around with forms to see what can and can't be done. I'm a learn by doing kind of bloke!

I have a form which takes different numbers. It then POST's the information to a simple PHP script which simply echo's whichever value I want it to so I can play with the form to see what works and what doesn't.

What I'm trying to do is have the form add up two values when you hit the submit button, then POST the answer as one of the hidden form values. This is what I'm trying to do rather than add up the sent values in the receiving PHP file. I can do that already, I wont learn anything from doing that.

How I've tried going about this at the moment is instead of having the form submit whan hitting the submit button, have it run a function which adds up the values, then submits the form. What actually happens though is that the webpage thinks about it for a bit, then just sits there and does nothing!

Here's the code I'm using. The form is called pl_pay.

In the header:

Code:
	function payform() {
	var total = first+amount;
	document.forms.pl_pay.write('<input type="hidden" name="totalamm" value="'+total+'">');
	document.forms.pl_pay.submit();
	}
Then on the submit button I've used a simple image with the href "javascriptayform();" (obviously that's a : and a p in there, not a poky tongue smiley!)

So what have I done wrong here? Probably about a hundred things in 4 lines of code...
javascript_beg is offline   Reply With Quote
Old July 30th, 2009, 01:44 PM     #2 (permalink)
Member
 
theGlitch's Avatar
 
Join Date: Jul 2008
Location: Boston, MA
Posts: 183
Blog Entries: 1
Send a message via AIM to theGlitch
I my self am still pretty new to JS... but in the AJAX book I'm reading (AJAX for Dummies) they talk about POST. See if the code below helps you out at all:

Quote:
function getOptions(scheme)
{
var url = "options3.php";

if(XMLHttpRequestObject) {
XMLHttpRequestObject.open("POST", url);
XMLHttpRequestObject.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');

XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {
var xmlDocument = XMLHttpRequestObject.responseXML;
options = xmlDocument.getElementsByTagName("option");
listOptions();
}
}

XMLHttpRequestObject.send("scheme=" + scheme);

}
}

theGlitch is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
beginner javascript, trying to put objects in array stupidity Saulg Webmastering and Programming 0 March 23rd, 2009 11:34 AM
Beginner in Javascript, need help with Firefox add-on gschmidt Webmastering and Programming 2 October 29th, 2008 07:54 PM
Beginner in Javascript I need help!! overdosed20 Webmastering and Programming 6 June 24th, 2008 12:34 PM
Beginner Javascript question James Engle Webmastering and Programming 0 April 21st, 2008 11:43 PM
Beginner, javascript code help! snikker74 Webmastering and Programming 4 April 4th, 2008 12:08 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2889)
Wireless Televisions. (6)
California Passes Anti-Flat-HDTV Le.. (39)
Obama the Muslim (14)
Is the PSU I received dead? (10)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
HIS HD5770 graphic card question (15)
Print spooler problem (13)
Foreign voltage (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
EVGA 9800 gtx help with finding a g.. (8)
New Computer wont recognize XP disc (7)
Recent Discussions
Point and Shoot Camera Suggestions. (0)
CPU fan stops spinning randomly (3)
wireless user (1)
windows 7 problem (1)
Modern Warfare 2 freeze (12)
Wireless Televisions. (6)
World's largest Monopoly Game using G.. (332)
Ideal cheap graph card for PC-Gaming? (17)
BIOS won't read disk when I try to fl.. (0)
Install XP pro and a Vista laptop ?? (11)
Partition Magic caused HDD problem (2)
Graphics Card Upgrade Question (1)
favorit (1)
solutions for virtical white lines on.. (1)
Regular Build (3)
Fire in DVD (2)
Modern Warfare For the PC (33)
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)


All times are GMT -4. The time now is 10:30 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28