473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Strange problem

Consider the form below. When I press "Concedi" button all parameters are
correctly sent to the destination page apart from "scadenza" that is sent as
"undefined". Can you give me an explanation of this?

<form name="operazioni_extra">
<table class="leghe_private">
<tr><td class="intestazione">[Nome lega]</td></tr>
<tr><td class="contenitore_invita_utente">
<table><tr><td class="subintestazione">Concedi operazioni extra</td></tr>
<tr><td class="regola_regolamento">Quante operazioni?&nbsp;<input
type="text" name="operazioni" size="3"><br>
Scadenza:<br><input type="radio" name="scadenza" value="indefinita">nessuna
scadenza.<br>
<input type="radio" name="scadenza" value="definita">tra <input type="text"
name="scad_giorni" size="3"> giorni.</td></tr>
<tr><td class="bottoni">
<input type="button" value="Annulla"
onClick="document.location.href='pannello_di_contr ollo.php?lega=[Nome
lega]&aspetto=extra'">
&nbsp;&nbsp;
<input type="button" value="Concedi"
onClick="document.location.href='pannello_di_contr ollo.php?lega=[Nome
lega]&aspetto=operazioni_extra_concesse&operazioni='+do cument.operazioni_extra.operazioni.value+'&scadenz a='+document.operazioni_extra.scadenza.value+'&sca d_giorni='+document.operazioni_extra.scad_giorni.v alue">
</td></tr></table></td></tr></table>
</form>

Thank you in advance for your support.

Cordially,
Mirco Soderi
Dec 20 '05 #1
6 1217
Mirco Soderi wrote:
Consider the form below. When I press "Concedi" button all parameters are
correctly sent to the destination page apart from "scadenza" that is sent as
"undefined". Can you give me an explanation of this?
perhaps
<form name="operazioni_extra">
name is deprecated - I believe that applies to forms as well. Use 'id'
instead.

Where is the rest of your declaration? (action, type?)
<input type="button" value="Concedi"
onClick="document.location.href='pannello_di_contr ollo.php?lega=[Nome
lega]&aspetto=operazioni_extra_concesse&operazioni='
+document.operazioni_extra.operazioni.value+'&scad enza='
+document.operazioni_extra.scadenza.value+'&scad_g iorni='
+document.operazioni_extra.scad_giorni.value">


Why are you using onclick here instead of putting
action='pannello_di_controllo.php' in your <form> tag?

There is no need for onclick that I can see - you would be better off
defining the form according to normal conventions.

Also - remember that you won't get a defined value if neither scadenza
option is selected - you may want to consider defining one as the
default selection.

Dec 20 '05 #2
On 20/12/2005 17:02, Mirco Soderi wrote:
Consider the form below.
Did that. Now I must wonder why on Earth you aren't submitting it with
two submit buttons. Instead of checking the 'aspetto' value for 'extra'
or 'operazioni_extra_concesse', name both buttons 'aspetto' and check
for 'Annulla' or 'Concedi', respectively[1].
When I press "Concedi" button all parameters are correctly sent to
the destination page apart from "scadenza" that is sent as
"undefined". Can you give me an explanation of this?


You have two controls named 'scadenza', so:

document.forms.operazioni_extra.elements.scadenza

evaluates to a collection (similar to an array) that references both
controls. This collection doesn't have a value property, so you quite
rightly obtain an undefined value.

What you need to do is determine which is selected and return the value
of that control:

function getCheckedValue(group, form) {
if('string' == typeof group) {
group = form.elements[group];
}
for(var i = 0, n = group.length; i < n; ++i) {
if(group[i].checked) {
return group[i].value;
}
}
}
getCheckedValue('scadenza', document.forms.operazioni_extra);

[snip]

If you post code in future, please present it nicely, and manually
wrapped to less than 75 characters.

Mike
[1] If IE wasn't so broken, you could use a BUTTON element
instead and avoid changing the server-side script.

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 20 '05 #3
Tony wrote:
Mirco Soderi wrote:
Consider the form below. When I press "Concedi" button all parameters are
correctly sent to the destination page apart from "scadenza" that is sent
as "undefined". Can you give me an explanation of this?
perhaps
<form name="operazioni_extra">


name is deprecated -


It is not.
I believe that applies to forms as well.
It does not.
Use 'id' instead.
There is no identifying attribute necessary here whatsoever, neither `id'
nor `name'. However, the `action' attribute is #REQUIRED for the `form'
element.
Where is the rest of your declaration? (action, type?)
<input type="button" value="Concedi"
onClick="document.location.href='pannello_di_contr ollo.php?lega=[Nome
lega]&aspetto=operazioni_extra_concesse&operazioni='
+document.operazioni_extra.operazioni.value+'&scad enza='
+document.operazioni_extra.scadenza.value+'&scad_g iorni='
+document.operazioni_extra.scad_giorni.value">

If scripting were required (which it is not, see below),

function submitData(b)
{
var f, el;
if (b && (f = b.form) && (el = f.elements))
{
var
dummy = function(x) { return x; },
esc = (typeof encodeURIComponent == "function"
? encodeURIComponent
: (typeof escape == "function" ? escape : dummy));

window.location =
'pannello_di_controllo.php?lega=%5bNome lega%5d'
+ '&aspetto=operazioni_extra_concesse'
+ '&operazioni=' + esc(el['operazioni'].value)
+ '&scadenza=' + esc(el['scadenza'].value)
+ '&scad_giorni=' + esc(el['scad_giorni'].value);
}

return false;
}

document.write(
'<input type="button" value="Concedi"'
+ ' onclick="return submitData(this);">');

would suffice. Note that some characters are not allowed unescaped in URIs,
see RFC3986.
Why are you using onclick here instead of putting
action='pannello_di_controllo.php' in your <form> tag?

There is no need for onclick that I can see - you would be better off
defining the form according to normal conventions.


Exactly, the OP is most certainly looking for <input type="submit" ...>
PointedEars
Dec 20 '05 #4
Michael Winter wrote:
If you post code in future, please present it nicely,
and manually wrapped to less than 75 characters.


I am OK with up to 76 characters.
PointedEars
Dec 20 '05 #5
Thomas 'PointedEars' Lahn said the following on 12/20/2005 2:51 PM:
Michael Winter wrote:

If you post code in future, please present it nicely,
and manually wrapped to less than 75 characters.

I am OK with up to 76 characters.


All stop the world!!! Thomas has proclaimed that 76 characters is fine
as opposed to 75.

You are in my sites boy.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 20 '05 #6
Randy Webb wrote:
[...]
You are in my sites ...

That's gotta be the worst web pun I've seen in quite a while. :-p


--
Rob
Dec 21 '05 #7

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

Similar topics

5
by: Rob Ristroph | last post by:
Hi, It's pretty unhelpful to post "I have a huge piece of code that crashes in strange places, what's the problem?" but that's basically my problem and I really am at my wit's end. The piece...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
1
by: Sam Kong | last post by:
Hello! Recently I had a strange problem with Visual C# 2005 beta 1. When I ran(F5 key) a program, <#if DEBUG> statement was not working. It ran as RELEASE mode. So I had to manually define...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
12
by: StephQ | last post by:
I have a class Bounds with two constructors: class Bounds { private: list<SegmentupperLinearSpline; // Upper bound. list<SegmentlowerLinearSpline; // Lower bound. ....
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
5
by: ioni | last post by:
Good day, fellows! I have a strange problem – at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.