So.. I have a form that submits to an ASP.net site made in C-sharp.
The ASP site is not mine, i do not have the server side code.
When I submit from my form by pressing the Submit button, I get
different results than when I use a javascript submit: form1.submit(); .
I think the javascript submit is working as it should, since I want
the server to process an __EVENTTARGET posting. When I click the
submit button, it does not process the __EVENTTARGET field. However,
it should really work the same way whether i click a button or whether
javascript submits, right? Why is there a difference? I used firefox
to see what fields were being posted to the server, and the POSTFields,
referrer, etc. all are identical.
Oh, btw, when I use libcurl to post the same fields, it does not
process the __EVENTTARGET either, as if I had clicked the submit button. 10 6087
ljlolel said the following on 5/17/2006 7:10 PM: So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code.
Irrelevant to client side Javascript.
When I submit from my form by pressing the Submit button, I get different results than when I use a javascript submit: form1.submit(); .
Then the form may have an onsubmit event handler that changes the form's
contents.
I think the javascript submit is working as it should, since I want the server to process an __EVENTTARGET posting. When I click the submit button, it does not process the __EVENTTARGET field. However, it should really work the same way whether i click a button or whether javascript submits, right?
No.
Why is there a difference?
Because they are submitted using different methods.
I used firefox to see what fields were being posted to the server, and the POSTFields, referrer, etc. all are identical.
Oh, btw, when I use libcurl to post the same fields, it does not process the __EVENTTARGET either, as if I had clicked the submit button.
Not sure what libcurl is.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
ljlolel wrote: So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code.
When I submit from my form by pressing the Submit button, I get different results than when I use a javascript submit: form1.submit(); . I think the javascript submit is working as it should, since I want the server to process an __EVENTTARGET posting. When I click the submit button, it does not process the __EVENTTARGET field. However, it should really work the same way whether i click a button or whether javascript submits, right?
When a form is submitted using a submit button a name/value pair for the
submit button used is sent with the request. If you use the - submit -
method of the form no submit button qualifies as 'successful' and no
name/value pair is sent. However, competent server-side script authors
will determine some default action to handle circumstances where the user
submits a form without using a submit button (browsers provide varied
mechanisms for doing so, including keyboard shortcuts).
Why is there a difference? I used firefox to see what fields were being posted to the server, and the POSTFields, referrer, etc. all are identical.
<snip>
Are they?
In any event, if this is not intended to be cross-browser you could
attempt to call the - click - method of the pertinent submit button to
submit the form (that would not be cross-browser because not all browsers
implement a - click - method on their submit buttons).
Richard.
There is no onsubmit event handler. To simplify everything, I wrote a
10-line form to submit to the server. When I click the submit button,
it doesn't register __EVENTTARGET. When i uncomment the submit()
function in the javascript, it does register this input and returns the
appropriate results.
I know this sounds really weird, and I wouldn't believe it if I hadn't
done it several times myself. I dont understand how there can be a
difference. Firefox lists all of the fields posted, and they are
identical whichever way I submit. The same inputs should yield the
same outputs, but for some reason something is very wrong.
Nevermind. Telling you is too hard and I sound crazy (I definetely
think I must be going nuts). Here is a link to my form: http://perla.princeton.edu/counselors/organization.php . It posts an
action to nacacnet.org.
Now, look at the code. No onsubmits, just a couple of necessary hidden
inputs. Now, if you click on the submit button, it takes you to
results 1-15, the first page, of the list of organizations. But, if
you run the submit() function through javascript, it goes to page 6
(which it should). Look at firefox's page info... it sends the same
info... but gets different results. If you solve this conundrum, you
should write the next da vinci code book ;-). jo*********@gma il.com a écrit : think I must be going nuts). Here is a link to my form: http://perla.princeton.edu/counselors/organization.php
Now, look at the code. No onsubmits, just a couple of necessary hidden inputs.
I've looked through the "code", i think you should start cleaning all
the HTML mess (missing tags, tags not allowed into another, missing
attributs, bad content-type, etc.) before thinking about getting
something reliable from javascript ! I'm gonna cut/paste some of the
markup, but around 10/15 HTML problems or warning in a 15 lines
document, i think it's too much.
Your page is served as text/html, so there is no need for the /> that's
can be seen everywhere on your page. Anyway, let's assume it's a quick
and dirty cut/paste from a real XHTML page but if so, the test page is
not acurate to the issue you encounter in real world. Sometimes the
javascript behavior is slightly different in HTML and XHTML. Is your
page HTML or XHTML ?
No doctype, that's a bad practice, please choose one.
<html>
<form method="post" name="MemberDir ectory" id="MemberDirec tory"
action="http://...Directory/?NRMODE=Publish ed&...">
Here the method is post but the action is looking like a get request. I
dont think it's clever to mix post and get requests. I bet the problem
you encounter is comming from this.
[snip]
</form>
<input type="submit" onclick="javasc ript:notfirstpa ge();" />
Again, no need for the /> if it's not a XHTML document.
Input tag outside a form ? The structure of a HTML document does not
allow to insert all type of tags in all conditions.
onclick="javasc ript: ... " is totally wrong, please just use
onclick="return my_function();"
And why use a submit type ? Don't you just want a button ?
<script language="JavaS cript">
If you are reading this newsgroup you should know by now this is the
crappiest way to insert a script. It's useless to use the language
attribute and the type attribute is required.
You should instead use <script type="text/javascript">
function notfirstpage()
{
form1 = document.forms["MemberDirector y"];
form1.submit();
}
Perhaps it would be wise to read the newsgroup before asking, or at
least read documentations.
when you do
form1 = document.forms["MemberDirector y"];
the variable "form1" is created in the global scope, you want here to
use a local variable, so you must use : var
var form1 = document.forms["MemberDirector y"];
Since notfirstpage() is the onclick handler, you must return true or
false to abort or keep running the event.
Anyway, imo the problem is inside the confusion between post method and
get url of the form's action.
--
laurent
laurent,
I coded this in a couple of minutes by hand, for the sole purpose of
showing this weird problem. I've moved to xhtml 1.0 transitional, even
though that matters not at all for a test page.
Your suggestion that it was a problem with the action url seemed like a
good one. Unfortunately, I just changed it, and it still doesn't work
:(. I still don't know what could possibly be the problem. http://perla.princeton.edu/counselors/organization.php
j
Laurent Vilday wrote:
[...] [snip]
</form> <input type="submit" onclick="javasc ript:notfirstpa ge();" />
Again, no need for the /> if it's not a XHTML document. Input tag outside a form ? The structure of a HTML document does not allow to insert all type of tags in all conditions.
Input elements can appear outside forms, however to use a type submit
outside a form doesn't make any sense. Maybe the button is outside the
form and using script to call the form's submit method in a lame attempt
to force the user to have JavaScript enabled or to try and force the
submit handler to run - neither outcome can be guaranteed and in both
cases an input type button would be more suitable.
The button should be inside the form and the onclick function should be
added to the form's onsubmit handler.
If the OP wants a reference to the submit button passed to the server,
give the button a name (anything other than 'submit'):
<form id="MemberDirec tory" onsubmit="notfi rstpage();" ...>
...
<input type="submit" name="MemberDir ectorySubmitBut ton">
</form>
Usually the function called onsubmit returns true or false, then the
handler returns whatever the function returns so that form submission
can be canceled by the function.
onclick="javasc ript: ... " is totally wrong, please just use onclick="return my_function();"
Don't use either, put the function on the form's submit handler.
[...]
function notfirstpage() { form1 = document.forms["MemberDirector y"]; form1.submit(); }
[...]
the variable "form1" is created in the global scope, you want here to use a local variable, so you must use : var
var form1 = document.forms["MemberDirector y"];
If it was necessary at all, then:
document.forms["MemberDirector y"].submit();
seems better, no variable needed.
Since notfirstpage() is the onclick handler, you must return true or false to abort or keep running the event.
No, it doesn't. If the button is outside the form, once the form's
submit() method is called, that's it. The function can then do what it
wants, it can no longer influence submission (maybe it could try to
interrupt submission by changing location.href or something silly but
that is unlikely to be robust).
If the function is put on the form's submit handler, it can stop
submission provided JavaScript is available, the function returns
-false- and the submit handler pass the returned value to the form, e.g.
<form ... onsubmit="retur n someFn();" ...>
Now if someFn returns false, it will be passed to the form and
submission will be stopped. However, if the onsubmit handler doesn't
pass on the value:
<form ... onsubmit="someF n();" ...>
someFn can return whatever it likes, the form will be submitted.
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/faq/>
Laurent Vilday <mo****@mokhet. com> writes: </form> <input type="submit" onclick="javasc ript:notfirstpa ge();" />
This looks fragile.
The onclick event calls a method that calls submit. Then the
event ends without cancelling the default behavior, and the
form is potentially submitted again.
Maybe a browser will stop after the first submit, but then again,
it might use the last navigation instead (I know that sometimes
after I press a link, but before the page is unloaded, I change
my mind and press another link ... and that works). You just
can't know for sure, so you should make sure exactly one of those
are possible.
So change this to:
<input type="submit" onclick="notfir stpage();return false;" value="..">
or even better:
<input type="button" onclick="notfir stpage();" value="..">
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
RobG wrote: <form id="MemberDirec tory" onsubmit="notfi rstpage();" ...> ... <input type="submit" name="MemberDir ectorySubmitBut ton"> </form>
Usually the function called onsubmit returns true or false, then the handler returns whatever the function returns so that form submission can be canceled by the function.
No, it does not do that automatically. You have to write
<form ... onsubmit="retur n notfirstpage(); " ...>
for that, as you explained below. It is also a Good Thing if the validating
function is passed `this', the reference to the DOM object representing the
`form' element, in order to access the form controls' value. Probably the
`form' element does not need an ID then anymore, as the required reference
is already there.
[snipped explanation on how to cancel the submit event]
PointedEars
--
Multiple exclamation marks are a sure sign of a diseased mind.
-- Terry Pratchett This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Xeon |
last post by:
Ok, the subject seemed not PHP related, but it does, as the submitted
form will be read/processed by PHP.
I have this HTML code:
<form method="post" action="foo.php">
<select name="blah" onChange="javascript:submit();">
<option selected value="1">opt1</option>
<option value="2">opt2</option>
<option value="3">opt3</option>
|
by: Margaret Werdermann |
last post by:
Hi all:
I'm having a nasty time with a particularly difficult piece of code
and was hoping someone might be able to help me. I have a FormMail
form that originally worked perfectly.
Then, I had to add a JavaScript function to the Submit button to make
a server function run when the form was submitted. Unfortunately,
this JavaScript wouldn't run when the button was designated as a
Submit, so I changed the button and placed a...
|
by: javascript_noob12 |
last post by:
Hi.
I am trying to create a CGI script that will use Perl to read a text file to
get a list of values, then turn that list into a menu on a website. The menu
will be a form with a JavaScript "submit" function. . When someone selects a
menu-item, the form will submit the value of that list-entry to another CGI
page.
The problem I'm encountering is that the script I've written submits every
value of the form rather than the one specific...
|
by: Joop |
last post by:
Hi all,
I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-)
So, here's my problem :
I've created a table in my document, presenting a list of items, one
can 'select' by clicking on it... (Kinda like a menu, you make your
choice from) But since this table can get very long, I've put
something of a 'search-form' on top, which enables the user to make a
|
by: michael.friis |
last post by:
Im currently trying to build a simple extension to a website allowing
me ot have a list of users in a frame beside the actual site.
Problem is the actual website uses javascript to update the contents of
dynamic pages so a link to a user on the website is:
javascript:SubmitMain("/traveller.asp","u~14756|flag~14756")
So what i did to make the userlist is make a simple framesite with one
column for the userlist and one big coloumn for the...
| |
by: ljlolel |
last post by:
I'm posting this again because I did not explain myself well the first
time, so the problem was not being addressed. I made the following
page ( http://perla.princeton.edu/counselors/organization.php ) solely
for the purpose of showing a bug. It is not production code, it is a
test, made for testing, so style really doesn't matter.
This page illustrates that, for some reason, clicking on the submit
button has a different effect on the...
|
by: winstontuck |
last post by:
Hi
I am fairly new to javascript and html and I have the following
problem.
I have a page lets say page1. When something changes on page1 i set a
variable PossiblePageChanged to true. On page1 I have a link with
the
following properties : <A href="applypage1settings..and some
otherstuffhere" onclick="return CheckforPossibleChanges()">Page2</a>
|
by: janulam |
last post by:
Hello,
I have following code snippet:
...
function submitForm() {
document.forms.submit();
}
..
|
by: Rabel |
last post by:
I am a flash designer so I dont know a whole lot about the javascript
submit buttons (I may not even be describing it right sorry) but here
is the code I am using.
<IMG name="Checkout" value="Checkout" SRC="imagesButtons/
purchaseButton_r2_c2.jpg" onMouseOver="this.src = 'imagesButtons/
purchaseButton_r2_c2_f2.jpg'" onMouseOut="this.src = 'imagesButtons/
purchaseButton_r2_c2.jpg'"
onClick="JavaScript:document.forms.submit()">
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |