JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 11th, 2004, 04:20 AM
JensS JensS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 JensS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Again submit()

Look at this:

<html><head> <title>Test</title>
<script type="text/javascript"> <!--
function CSubmit() {document.form[0].submit();}
//--> </script>
</head><body>
<form name="inputform" action="test.html" method="get" >
<input type="text" name="inlo" value=""><br>
<a href="test.html" OnClick="CSubmit()">Transfer Data by JS-submit()</a><br>
<input type="submit" value="Transfer Data /w Submit-Button"></form>
</body></html>

Clicking the button, Get-data are being sent, but clicking the link, the page is being reloaded, but no data are being sent. What's wrong?????? What can I do to make the submit() function send data?


Reply With Quote
  #2  
Old July 11th, 2004, 07:22 AM
JensS JensS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 JensS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Link


Reply With Quote
  #3  
Old July 11th, 2004, 07:44 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Yes - clicking the link will of course reload the page, because it is a hyperlink. Take out the URI from the HREF portion. You can use onclick's on other items, such as a DIV, which I would do in this instance.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #4  
Old July 12th, 2004, 05:02 AM
JensS JensS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 JensS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow well...

Thank You for Your answer. Of course, the page is reloaded, which is what I want. The problem is, that submit() is not being executed. What does work is a href="javascript:document.form[0].submit()", but in my case I need a function, and href="javascript:CSubmit()" doesn't work either. The question is: Why not?? and: How??.
With DIV it's the same drama. The function CSubmit isn't executed, an error message appears.

Reply With Quote
  #5  
Old July 12th, 2004, 05:21 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
It doesn't work because you're trying to do 2 things at once. Instead, just submit the form normally (to your CGI script), then once the form has been processed on the server, you can redirect back to where-ever. You can't redirect on the client side after submitting the form. If you simply must submit the form using JS, then do it like this: "<a href="javascript:CSubmit()">submit</a>" - note that using this method will exclude all users with JS turned off.

Reply With Quote
  #6  
Old July 12th, 2004, 05:30 AM
JensS JensS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 JensS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
is it a browser-problem?

Yes, what you're writing should work, but it doesn't. Somehow, my browser just tells me "error on page". If CSubmit just contains e.g.window.prompt('xx') it works, but if it contains e.g. alert('xx') or (and that's the problem) submit(), it doesn't. Do you have any idea, why?

Reply With Quote
  #7  
Old July 12th, 2004, 05:35 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Ahh - found your problem - you are using document.form[0], when it should be document.forms[0]!

Reply With Quote
  #8  
Old July 12th, 2004, 05:42 AM
JensS JensS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 JensS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile thx

I was just gonna say, I think it's just some really stupid spelling mistake. Thanx a lot!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Again submit()


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway