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 08-31-2004, 10:38 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
javascript riddle: why won't my form submit from this text link?

today i ran into a problem. i've figured it out, but i wanted to post it in case anyone else didn't know or wanted to have a little fun.

so here is the question: why won't this form submit with the text link below.

mypage.html
PHP Code:
<html>
<
head>
  <
script language=javascript>
  function 
submitForm(){
    
document.myform.submit();
  }
  
</script>
</head>
<body>
<form name=myform method=post action=mypage.html>
<input type=text name=field1> <input type=submit name=submit>
</form>

<a href="javascript:submitForm()">submit this form</a>
</body>
</html> 
i'm sure someone will get it, but if not, i'll post the answer later.
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 08-31-2004, 07:07 PM   #2 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
is the space between java and script a typo?

(does it also require a trailing ; ? )
-r
__________________
idx is offline   Reply With Quote
Old 08-31-2004, 07:52 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
lol yeah, that is a typo sorry, .. the problem is that you can not name a button 'submit' if you are using document.myform.submit()

it thinks submit it the button when you type document.myform.submit .. and then it says you don't have a submit function.
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 08-31-2004, 09:01 PM   #4 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Posts: 56
Rotkiv is on a distinguished road
Send a message via AIM to Rotkiv Send a message via MSN to Rotkiv
once i was making a site and i had a really cool JS dropdown menu that i downloaded from a free Javascript site. I'd played around with it enough that i knew how to customize it, so i decided to put into one of my pages. Major problems, what the heck was causing it i knew not. looking through the js code i found that they were using a function or something called 'navigate' which is what i usually call my tables.

just one of my web experiences.
__________________
Rotkiv is offline   Reply With Quote
Old 09-01-2004, 04:36 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
yeah, i named one of my fields 'goto' yesterday as well .. apparently that is a key word too. i could not dynamically set the value of document.myform.goto.value. heh, javascript gotchas
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 09-22-2004, 05:17 AM   #6 (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
I ran into another problem doing the same thing a while back. I was submitting a form with a link, and i had to specify the method="post" in the in-line javascript. I posted a thread on this forum about it.

Code:
<a href="#" onclick="javascript:myform.method='POST';java script:myform.submit()">CLICK HERE</a>
__________________
sammy is offline   Reply With Quote
Old 09-29-2004, 05:56 AM   #7 (permalink)
dirs
Registered User
 
Join Date: May 2004
Posts: 40
dirs is on a distinguished road
Instead of
<script language=javascript>
u should have
<script language="JavaScript" type="text/JavaScript">
__________________
dirs 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
Using javascript to submit a form sammy HTML, XML, Javascript, AJAX 2 07-15-2004 01:31 PM
Capturing web page text vaclav VB 6 0 02-24-2003 02:42 PM
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 5 07-07-2002 09:54 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 02:18 AM.


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