473,715 Members | 5,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Another Form Question

Tom
I have created the following code for a product select/payment form (don't know if there is a better
way) and I have been trying to make the following changes (unsuccessfully so far):

1) Eliminate the submit button and submit the form with onchange.
2) Open the action php page in a new window.

I am using this code for different payment options (i.e., cc processing and paypal). As such, there
are multiple forms on the page. The coding must be done in XHTML-Strict so I cannot use the name or
target attributes with FORM.
---------------
// Script
var Prices = new Array();
Prices[00] = "10.00";
Prices[01] = "12.50";
Prices[02] = "15.00";
Prices[03] = "20.00";
Prices[04] = "40.00";
Prices[05] = "60.00";
Prices[06] = "15.00";
Prices[07] = "20.00";
Prices[08] = "30.00";
Prices[09] = "45.00";
Prices[10] = "90.00";
Prices[11] = "150.00";
var Descriptions = new Array();
Descriptions[00] = '0.5 liter UNGLAZED Ceramic Bowl';
Descriptions[01] = '0.75 liter UNGLAZED Ceramic Bowl';
Descriptions[02] = '1.0 liter UNGLAZED Ceramic Bowl';
Descriptions[03] = '1.5 liter UNGLAZED Ceramic Bowl';
Descriptions[04] = '3.0 liter UNGLAZED Ceramic Bowl';
Descriptions[05] = '5.0 liter UNGLAZED Ceramic Bowl';
Descriptions[06] = '0.5 liter GLAZED Ceramic Bowl';
Descriptions[07] = '0.75 liter GLAZED Ceramic Bowl';
Descriptions[08] = '1.0 liter GLAZED Ceramic Bowl';
Descriptions[09] = '1.5 liter GLAZED Ceramic Bowl';
Descriptions[10] = '3.0 liter GLAZED Ceramic Bowl';
Descriptions[11] = '5.0 liter GLAZED Ceramic Bowl';

function updateXYform()
{
var i;
i = document.forms[0].xyselectamtand desc.selectedIn dex;
if(i > 0) {i = (i - 1);}
document.forms[0].amount.value = Prices[i];
document.forms[0].product_name.v alue = Descriptions[i];
}

//XHTML

<form id="xyform" action="http://www.myurl/order.php" method="post">
<input type="hidden" name="email" value="bl**@whe reever.com" />
<input type="hidden" name="descripti on" value="Red" />
<input type="hidden" name="amount" value="" />
<input type="hidden" name="product" value="" />
<select name="xyselecta mtanddesc" onchange="updat eXYform();">
<option selected="selec ted">Select Here...</option>
<optgroup label="Ceramic (unglazed)">
<option>0.5 L-$10.00</option>
<option>0.75 L-$12.50</option>
<option>1.0 L-$15.00</option>
<option>1.5 L-$20.00</option>
<option>3.0 L-$40.00</option>
<option>5.0 L-$60.00</option>
</optgroup>
<optgroup label="Ceramic (glazed)">
<option>0.5 L-$15.00</option>
<option>0.75 L-$20.00</option>
<option>1.0 L-$30.00</option>
<option>1.5 L-$45.00</option>
<option>3.0 L-$90.00</option>
<option>5.0 L-$150.00</option>
</optgroup>
</select>
<input type="submit" value="Buy Now" />
</form>
I tried adding the following command to the function statement

if(document.for ms[0].xyselectamtand desc.selectedIn dex > 0)
{
window.open('ht tp://www.myURL/order.php','new Window');
}

and deleting the <input type="submit".. .> command. The new window opens but no form data is POSTed.

Any suggestions and help is appreciated.... Tom
Jul 20 '05 #1
9 2017

"Tom" <sa*******@cox. net> wrote in message
news:PrzRb.5181 $fD.2606@fed1re ad02...
: I have created the following code for a product select/payment form (don't
know if there is a better
: way) and I have been trying to make the following changes (unsuccessfully
so far):
:
: 1) Eliminate the submit button and submit the form with onchange.
: 2) Open the action php page in a new window.
:
:
: <form id="xyform" action="http://www.myurl/order.php" method="post">

change this in:

<form id="xyform" action="http://www.myurl/order.php" method="post"
target="_blank" >

and it will open in a new window.
: <select name="xyselecta mtanddesc" onchange="updat eXYform();">

change this in:

<select name="xyselecta mtanddesc"
onchange="docum ent.forms['xyform'].submit();">
Wouter
Jul 20 '05 #2
Tom
Thanks for the help Wouter, but your solutions are also giving me problems...
: <form id="xyform" action="http://www.myurl/order.php" method="post">

change this in:

<form id="xyform" action="http://www.myurl/order.php" method="post"
target="_blank" >

and it will open in a new window.
As I said "The coding must be done in XHTML-Strict so I cannot use the name or target attributes
with FORM."
In XHTML-Strict, the TARGET attribute is depreciated, therefore I do not want to use code I will
have to change in a few month/years when browsers become more compliant with the standards.
: <select name="xyselecta mtanddesc" onchange="updat eXYform();">

change this in:

<select name="xyselecta mtanddesc"
onchange="docum ent.forms['xyform'].submit();">


Although this code will cause the form to be submitted with the "onchange" command the form does not
go to the array and update the document for the fields 'amount' and 'description'. The command
submits the text description in the select field which is not recognized by the php page.

Jul 20 '05 #3
Tom
Please note the following correction...
document.forms[0].product_name.v alue = Descriptions[i];
should be
> document.forms[0].product.value = Descriptions[i];


Jul 20 '05 #4
Tom
grrrrr, typing to fast here...

Although this code will cause the form to be submitted with the "onchange" command the form does not
go to the array and update the document for the fields 'amount' and *** 'description' ***. The
command
submits the text description in the select field which is not recognized by the php page.
Should be *** 'product' ***

Jul 20 '05 #5
@SM
Tom a ecrit :

I have been trying to make the following changes (unsuccessfully so far):
I do not know XHTML, but ...
1) Eliminate the submit button and submit the form with onchange.
function updateXYform(my FormSelect) {
var i = (myFormSelect.o ptions.selected Index>0)? i-1 : '' ;
if(document.get ElementById) {
document.getEle mentById('amoun t').value = Prices[i];
document.getEle mentById('produ ct_name').value = Descriptions[i];
document.getEle mentById('xyfor m').submit();
}
else
with(document.f orms['xyform']) {
amount.value = Prices[i];
product_name.va lue = Descriptions[i];
submit();
}
}

<select name="xyselecta mtanddesc" onchange="updat eXYform(this);" >
2) Open the action php page in a new window.


<form id="xyform" name="xyform" action="http://www.myurl/order.php" method="post" target="_blank" >
--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:st****** *************** @wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
*************** *************** *************** *************** **
Jul 20 '05 #6
On Tue, 27 Jan 2004 12:59:56 -0700, Tom <sa*******@cox. net> wrote:
I have created the following code for a product select/payment form
(don't know if there is a better way) and I have been trying to
make the following changes (unsuccessfully so far):

1) Eliminate the submit button and submit the form with onchange.
Why on Earth would you want to do that? It is an extremely bad idea. The
onchange event can be fired differently from each of the various elements.
For example, a SELECT menu might fire it when someone uses the mouse wheel
to scroll the options.

Users don't expect something as final as a form submission to occur when
they choose from a radio group, a series of checkboxes, or a menu. Don't
fiddle with the user's expectation of browser behaviour, especially with
something as critical as an e-commerce system. Keep the submit button - I
really don't see any reason reason for not using it.
2) Open the action php page in a new window.


[snip]

Without specifying the target attribute, I don't think you can. The
general format is (from the FAQ):

<form ... target="wndname "
onsubmit="windo w.open('',this. target,'feature s');return true;">

The new window is created with the appropriate name. The target attribute
uses the same name, so the submission is directed there. Without the
target attribute, the results are not redirected. If it were a GET
submission, it would be possible; you would just create the query string
yourself and use that for the URI of the new window. However, this is not
possible with POST.

I would recommend altering the page layout generated by the server to keep
whatever information you need from the original page on the submission
page.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #7
@SM
Tom a ecrit :

Thanks for the help Wouter, but your solutions are also giving me problems...
<form id="xyform" action="http://www.myurl/order.php" method="post"
target="_blank" >
As I said "The coding must be done in XHTML-Strict so I cannot use the name or target attributes
with FORM."
In XHTML-Strict, the TARGET attribute is depreciated,


I know that, but :
- or it is no more allowed to open a new window
- or there is an other way to do that in XHTML
which one ? don't know. You'll tell it.
<select name="xyselecta mtanddesc"
onchange="docum ent.forms['xyform'].submit();">


Although this code will cause the form to be submitted with the "onchange" command the form does not
go to the array and update the document for the fields 'amount' and 'description'.


and doing :
onchange="yourf unctionIforgot( ); this.form.submi t();"
??

and to feed the php
would itn't be better
<form method="get"
?

--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:st****** *************** @wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
*************** *************** *************** *************** **
Jul 20 '05 #8

: Although this code will cause the form to be submitted with the "onchange"
: command the form does not
: go to the array and update the document for the fields 'amount' and
'description'.
: The command
: submits the text description in the select field which is not recognized
by the
: php page.

Hmm, why don't you put the arrays in the PHP script?
Save a bit Javascript worries..

wouter
Jul 20 '05 #9
"Tom" <sa*******@cox. net> wrote in message
news:PrzRb.5181 $fD.2606@fed1re ad02...
I have created the following code for a product select/payment
form (don't know if there is a better way) and I have been
trying to make the following changes (unsuccessfully so far):
So this is a commercial project?
1) Eliminate the submit button and submit the form with
onchange.
And you want to take something that would be capable of functioning
(i.e. taking the money from the customer) without JavaScript and render
it both JavaScript dependent and potentially difficult to use for anyone
who does not have (or prefers not to use (such as experienced lap-top
users) a mouse as their input device. In a commercial context forcing an
unnecessary dependence on JavaScript is potentially turning away 5-20%
(depending on who's figures you trust (if any)) of potential customers
at the design stage. Does the client appreciate that you are designing
him/her out of potential business?
2) Open the action php page in a new window.
And now, in addition to that JavaScript dependence you are going to turn
away customers who use pop-up blocking mechanisms and browsers that are
incapable of displaying additional windows. That may even be a bigger
proportion of potential customers than those who cannot use JavaScript
(and probably not groups that will overlap as the JavaScript
incapable/disabled won't see much need for pop-up blockers).

There are also variants on pop-up blocking mechanisms that force
attempts to open new windows to open the referred URL in the current
window. Meaning that any design that makes sense in multiple windows
should also make sense as a sequence of pages in the current window.
Significantly increasing the complexity of the coding for the back end,
but at least allowing the users of browsers that cannot open new window
to successfully make purchases on the resulting site.
I am using this code for different payment options (i.e., cc
processing and paypal). As such, there are multiple forms
on the page. The coding must be done in XHTML-Strict so I
cannot use the name or target attributes with FORM.
So you wouldn't interpret the removal of target attributes in (x)HTML
strict as implying that if you write strict you should not be attempting
to open new windows at all? Surly if that wasn't the intended
consequence of removing the target attribute there would have been no
reason to remove it.

But XHTML doesn't sit well with commercial projects in a work where the
most popular browser (window IE) does not understand XHTML at all.
Presumably you are going to be writing Appendix C XHTML and serving it
as content-type: text/html so IE will respond to the content type and
error-correct the source back to HTML and build and HTML DOM for you to
script.

Indeed most browsers will respond to the content-type and error-correct
the source back to HTML and build an HTML DOM with it. Meaning the use
of Appendix C XHTML does nothing except burden the users system with the
additional task of error-correcting what the browser has no choice but
interpret as dubious HTML source code.

The problem arises when you read reports (on Usenet, so not necessarily
valid) of browsers getting Appendix C XHTML source served as text/html
and reading their DOCTYPE declarations, finding that they claim to be
XHTML and building an XHTML DOM from them. (This would seem to be a
foolish and arguably incorrect strategy for any browser to adopt, but
foolish and arguably incorrect behaviour from web browsers is something
we have all had to come to live with).

An XHTML DOM (even when they have been around long enough for consistent
patterns in their implementation to emerge) is in many respects very
different from an HTML DOM. So if authoring Appendix C XHTML can result
in the construction of both an HTML on some browsers and an XHTML DOM on
others then any script that is going to attempt to interact with
whichever DOM is created is not only going to have to do all the work to
cope with inconsistencies in HTML DOMs it is also going to have to
repeat much of that work in an XHTML style to cope with XHTML DOMs.

Personally I don't think that XHTML will be appropriate in a commercial
context until the majority of browsers can successfully interpret it
when served with its correct content type. In the mean while burdening
the user with the error-correcting overhead and yourself with the extra
work of scripting for even greater potential diversity in the
constructed DOM seems like a waste of resources without any return.

Probably better to write HTML strict and have the browsers understand it
as what it is and attempt to build only HTML DOMs from it. Though if the
strict DTD stands in the way of a design requirement something is wrong.
Either the designer doesn't understand the consequences of the
requirement to use a strict DTD (and so is not qualified to do their
job) or whoever set the requirement for the use of a strict DTD with the
design didn't appreciate that they would be irreconcilable (meaning they
were not qualified to make that decision).

<snip> function updateXYform()
{
var i;
i = document.forms[0].xyselectamtand desc.selectedIn dex;
if(i > 0) {i = (i - 1);}
document.forms[0].amount.value = Prices[i];
document.forms[0].product_name.v alue = Descriptions[i];
}
Mozilla's current XHTML DOM implementation does not have any of the
convenience properties on the document object so there is no
document.forms collection.

<snip>I tried adding the following command to the function statement

if(document.fo rms[0].xyselectamtand desc.selectedIn dex > 0)
{
window.open('ht tp://www.myURL/order.php','new Window');
}
Not all browsers have a window.open function so calling it unverified
will generate JavaScript errors in those.
and deleting the <input type="submit".. .> command. The new
window opens but no form data is POSTed.


If you insist that the submission is a POST then there is nothing you
can do except switch to a DTD that allows target attributes. Otherwise
you could append a GET request query string to the URL provided as the
parameter on the new window. Then you can cross your fingers and hope
that the user's system is going to be able to open the window else
that's another interested customer heading back to google to look for a
more competent retailer.

Richard.
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1090
by: Roy | last post by:
Hi all, I need a control on another form gets focus as soon as another form is closed. Form A and B are not mdi forms and both have been instantiated from FormA and FormB class. I'm not sure if the following approach is correct, if it's what should be the question mark? Dim f as Form Dim c as Control
1
1554
by: Primerov | last post by:
Why i cannot update from another form? I have an update function called UpdateData that works otherwise,but not from another form. Why is it so? I am trying to update tables from the form F1.There i have the following code : DoCmd.OpenForm " F2" UpdateData
7
6202
by: Dave | last post by:
I have two forms, Form1 and Form2. From Form2, how do I reference the value in a control on Form1? Or perhaps a more specific question: Form1 contains a textbox with the value of 10. This form is hidden. Form2 is active and a user enters a value of 2 into a blank text box. How can I add this value to the textbox in Form1 so that when Form1 is displayed it's textbox displays 12? I probably have the wrong mindset here; I'm thinking...
2
11129
by: authorking | last post by:
How to access a control in another form and how to make a form become a MDI container.
1
3877
by: Jeff | last post by:
Hello All: I have recently upgraded to VB .Net 2003 from VB6 and am having a little trouble. I have a MDI parent form that has a frame on it with a list box on the frame. I open an MDI child form and the frame on the parent form is still visible. What I want to do is run an OLEDBCommand on the child form and use the value of the item selected in the list on the parent form
4
9860
by: jaYPee | last post by:
I know how to open a form from another form. Say open form2 from form1 using a command button. But my problem is everytime I clicked the button it open again another instance of that form. here's my code Dim Course As New Course Course.Show() My question is on how to prevent a form from opening again if it is
5
1362
by: AMP | last post by:
Hello, Form1 has a button that creates Form2 that has a button that changes a lable on Form1. How do I give(send) Form2 a reference to Form1? Thanks Mike
2
5878
by: SePp | last post by:
Hi all. I want to refresh a Datagrid from another form. For Example I have a Datagrid in that I want to edit data. The user has the ability to press a button to change these data. A new Form opens and the user changes the data. After that he saves the changes and the current form is closing and the old form with the datagrid gets the focus again.
1
1952
by: viranadim | last post by:
I am having problems with attempting to filter a form based on criteria selected in a combo box from another form. I am attempting to filter a form called "Ford CheckList" that is based on a table called "Ford Returned Warranty Parts List". I am using the catagory "Program" that is in a combobox called "Program_Combo" which is located on a form called "Ford Database: Choose an Option". I want the user to open the form "Ford Database: Choose an...
0
8718
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,...
0
9343
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9198
jinu1996
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...
0
9047
tracyyun
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...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
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();...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.