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

Reply
 
LinkBack Thread Tools Display Modes
Old 08-31-2004, 11:38 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
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.
__________________
Mike
sde is offline   Reply With Quote
Old 08-31-2004, 08: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, 08:52 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
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.
__________________
Mike
sde is offline   Reply With Quote
Old 08-31-2004, 10:01 PM   #4 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Location: Silicon Valley, CA
Posts: 64
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, 05:36 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
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
__________________
Mike
sde is offline   Reply With Quote
Old 09-22-2004, 06: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, 06: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

Bookmarks

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

BB 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
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 16 09-22-2008 12:59 AM
javascript + asp submit problem RusH HTML, XML, Javascript, AJAX 1 11-04-2004 10:26 AM
Using javascript to submit a form sammy HTML, XML, Javascript, AJAX 2 07-15-2004 02:31 PM
Passing form data to PHP with Javascript bdl PHP 5 07-03-2002 11:18 AM


All times are GMT -8. The time now is 12:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting