Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > HTML, XML, Javascript, AJAX
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 07-14-2004, 06:12 PM   #1 (permalink)
sammy
Code Monkey
 
sammy's Avatar
 
Join Date: Jun 2004
Location: Brooklyn/Rochester
Posts: 53
sammy is on a distinguished road
Send a message via AIM to sammy
Using javascript to submit a form

Ok, so I want to submit a form with javascript. But the thing is, i want to use the post method. So that the information is hidden to the user.

Code:
<? print($_POST['sammy']); ?> <form name="myform" action="test1.php" method="POST"> <input type="hidden" name="sammy" value="sammy"> <a href="#" onclick="javascript:myform.submit()">CLICK HERE</a> </form> <script type="text/javascript" language="javascript"> <!-- function sub(){ document.myform.submit(); } //--> </script>
when i click the link, it shows this url on the browser :
/test1.php?sammy=sammy
__________________

Last edited by sammy : 08-11-2004 at 08:54 AM.
sammy is offline   Reply With Quote
Old 07-15-2004, 08:07 AM   #2 (permalink)
sammy
Code Monkey
 
sammy's Avatar
 
Join Date: Jun 2004
Location: Brooklyn/Rochester
Posts: 53
sammy is on a distinguished road
Send a message via AIM to sammy
Ok, i found the way to do it.
Code:
<a href="#" onclick="javascript:myform.method='POST';javascript:myform.submit()">CLICK HERE</a>
I had to manually change the form method property before i submitted, which i dont understand why, because shouldnt it be set when i did it in the form tag? I mean the action value was taken in, how come not the method?

wierd...eh?
__________________
sammy is offline   Reply With Quote
Old 07-15-2004, 01:31 PM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
Javascript is just weird in general.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript + asp submit problem RusH HTML, XML, Javascript, AJAX 1 11-04-2004 09:26 AM
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM
javascript riddle: why won't my form submit from this text link? sde HTML, XML, Javascript, AJAX 6 09-29-2004 05:56 AM
Javascriptin' like there ain't no tomorrow saline Saline's Brain Teasers 7 03-12-2003 01:17 AM
Passing form data to PHP with Javascript bdl PHP 5 07-03-2002 10:18 AM


All times are GMT -8. The time now is 11:51 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle