|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
|
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
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.
|
|
#6
|
|||
|
|||
|
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?
|
|
#7
|
||||
|
||||
|
Ahh - found your problem - you are using document.form[0], when it should be document.forms[0]!
|
|
#8
|
|||
|
|||
|
I was just gonna say, I think it's just some really stupid spelling mistake. Thanx a lot!
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Again submit() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|