473,830 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change hidden input value

I've been fighting with this for an hour.

My form contains a hidden input with the value initially set to "".

When a user clicks on the link, a function is called that updates the hidden
form value and submits the form.

Unfortunately this generates an error which states the form object is
undefined.

The function looks like

<script type='text/javascript'>
function submitLink(theF orm, theName, theValue) {
document.theFor m.theName.value = theValue;
document.theFor m.submit();
}
</script>

The form looks like

<form action="product/details" method="post" name="catxml" />
<input type="hidden" name="familyid" value="" />
<a href="javascrip t: submitLink(docu ment.catxml, familyid, '456');">Produc t
1</a>
</form>

The error reports that 'familyid is undefined'.

Can someone clue me in? Thanks.
Jan 30 '07 #1
4 45850

On Jan 30, 2:35 pm, "Bosconian" <nob...@nowhere .com>
wrote:
My form contains a hidden input with the value initially
set to "". When a user clicks on the link, a function is
called that updates the hidden form value and submits the
form.

<script type='text/javascript'>
function submitLink(theF orm, theName, theValue) {
document.theFor m.theName.value = theValue;
theForm [ theName ] . value = theValue ;
document.theFor m.submit();
theForm . submit ( ) ;
}
</script>

<form action="product/details" method="post"
name="catxml" />
Utter nonsense. The trailing slash in XML denotes a
childless element. That is, the following two notations are
semantically identical:

<form/>

and

<form></form>

Later on there's a closing tag for the form element in your
document. As it is, it doesn't make any sense--the document
is neither XML nor HTML. I'd strongly advise sticking to
HTML 4.01 Strict, at least until you start getting some
understanding of the matter.
<input type="hidden" name="familyid" value="" />
<a href="javascrip t: submitLink(docu ment.catxml,
familyid, '456');">Produc t 1</a>
<a
onclick=
"
submitLink
(
document . forms [ 0 ] , 'familyid', '456'
) ;
">
Product 1
</a>
</form>

The error reports that 'familyid is undefined'.
Naturally. Is familyid defined, after all? Not in the code
snippet you showed us, anyway.
Can someone clue me in? Thanks.
Without meaning to be rude, you managed to demonstrate
appaling ignorance in just a few lines of code. Either read
some good literature on the matter (and I don't mean just
JavaScript, your understanding is obviously just as lacking
where HTML and XML are concerned), find yourself a capable
mentor willing to teach you, or give it up.

--
Pavel Lepin

Jan 30 '07 #2
<p.*****@ctncor p.comwrote in message
news:11******** *************@q 2g2000cwa.googl egroups.com...
>
On Jan 30, 2:35 pm, "Bosconian" <nob...@nowhere .com>
wrote:
>My form contains a hidden input with the value initially
set to "". When a user clicks on the link, a function is
called that updates the hidden form value and submits the
form.

<script type='text/javascript'>
function submitLink(theF orm, theName, theValue) {
document.theFor m.theName.value = theValue;

theForm [ theName ] . value = theValue ;
> document.theFor m.submit();

theForm . submit ( ) ;
> }
</script>

<form action="product/details" method="post"
name="catxml " />

Utter nonsense. The trailing slash in XML denotes a
childless element. That is, the following two notations are
semantically identical:

<form/>

and

<form></form>

Later on there's a closing tag for the form element in your
document. As it is, it doesn't make any sense--the document
is neither XML nor HTML. I'd strongly advise sticking to
HTML 4.01 Strict, at least until you start getting some
understanding of the matter.
><input type="hidden" name="familyid" value="" />
<a href="javascrip t: submitLink(docu ment.catxml,
familyid, '456');">Produc t 1</a>

<a
onclick=
"
submitLink
(
document . forms [ 0 ] , 'familyid', '456'
) ;
">
Product 1
</a>
></form>

The error reports that 'familyid is undefined'.

Naturally. Is familyid defined, after all? Not in the code
snippet you showed us, anyway.
>Can someone clue me in? Thanks.

Without meaning to be rude, you managed to demonstrate
appaling ignorance in just a few lines of code. Either read
some good literature on the matter (and I don't mean just
JavaScript, your understanding is obviously just as lacking
where HTML and XML are concerned), find yourself a capable
mentor willing to teach you, or give it up.

--
Pavel Lepin
You are right about one thing. I'm a backend developer. We usually leave the
front-end stuff to "webmasters " and HTML jockeys like yourself.

I have to wonder though, why would anyone even bother spending the time to
craft a response like yours?

I suppose one can hardly blame you. You have to go through life with the
name "Pavel Lepin", the guy who got pounded daily in high school and who's
never kissed a girl. I suspect being a webmaster is really the only thing
you're good at. Just keep tell yourself, "chicks dig HTML."

Have a nice day.

Jan 30 '07 #3
<p.*****@ctncor p.comwrote in message
news:11******** *************@q 2g2000cwa.googl egroups.com...
>
On Jan 30, 2:35 pm, "Bosconian" <nob...@nowhere .com>
wrote:
>My form contains a hidden input with the value initially
set to "". When a user clicks on the link, a function is
called that updates the hidden form value and submits the
form.

<script type='text/javascript'>
function submitLink(theF orm, theName, theValue) {
document.theFor m.theName.value = theValue;

theForm [ theName ] . value = theValue ;
> document.theFor m.submit();

theForm . submit ( ) ;
> }
</script>

<form action="product/details" method="post"
name="catxml " />

Utter nonsense. The trailing slash in XML denotes a
childless element. That is, the following two notations are
semantically identical:

<form/>

and

<form></form>

Later on there's a closing tag for the form element in your
document. As it is, it doesn't make any sense--the document
is neither XML nor HTML. I'd strongly advise sticking to
HTML 4.01 Strict, at least until you start getting some
understanding of the matter.
><input type="hidden" name="familyid" value="" />
<a href="javascrip t: submitLink(docu ment.catxml,
familyid, '456');">Produc t 1</a>

<a
onclick=
"
submitLink
(
document . forms [ 0 ] , 'familyid', '456'
) ;
">
Product 1
</a>
></form>

The error reports that 'familyid is undefined'.

Naturally. Is familyid defined, after all? Not in the code
snippet you showed us, anyway.
>Can someone clue me in? Thanks.

Without meaning to be rude, you managed to demonstrate
appaling ignorance in just a few lines of code. Either read
some good literature on the matter (and I don't mean just
JavaScript, your understanding is obviously just as lacking
where HTML and XML are concerned), find yourself a capable
mentor willing to teach you, or give it up.

--
Pavel Lepin
Hi Pavel,

I wanted to let you know that you inspired me "not to suck." As a result of
you being a complete jerk and arrogant asshole, I pushed on ahead and
discover the error in my ways.

Best of luck belittling future posters and here's hoping you get laid
someday.
Jan 30 '07 #4

"Bosconian" <no****@nowhere .comwrote in message
news:lc******** *************** *******@comcast .com...
I've been fighting with this for an hour.

My form contains a hidden input with the value initially set to "".

When a user clicks on the link, a function is called that updates the
hidden form value and submits the form.

Unfortunately this generates an error which states the form object is
undefined.

The function looks like

<script type='text/javascript'>
function submitLink(theF orm, theName, theValue) {
document.theFor m.theName.value = theValue;
document.theFor m.submit();
}
</script>

The form looks like

<form action="product/details" method="post" name="catxml" />
<input type="hidden" name="familyid" value="" />
<a href="javascrip t: submitLink(docu ment.catxml, familyid,
'456');">Produc t 1</a>
</form>

The error reports that 'familyid is undefined'.

Can someone clue me in? Thanks.
For those of you playing along at home, here's how the code ended up:

<script type='text/javascript'>
function submitLink(theF orm, theName, theValue) {
theForm.element s[theName].value = theValue;
theForm.submit( );
}
</script>

<form action="product/details" method="post" name="catxml">
<input type="hidden" name="familyid" value="" />
<a href="javascrip t: submitLink(docu ment.catxml, 'familyid',
'455');">Produc t 1</a>
</form>

I made two corrections:

1) The first parameter in the function call already included the document
object and the duplicate was removed from within the function.
2) The second parameter is a variable string reference of the form element
and needed to be handled as such.

As it turns out, familyid was indeed defined and clearly evident in the
form--it just wasn't being referenced properly.

Lessons learned:

1) Coding while sleep-deprived only leads to sloppy mistakes and oversights.
2) Ignore arrogant assholes who have nothing to contribute to the community
except unconstructive criticism and negativity.

While on the subject, Pavel evidently thought the code was XML because the
opening form tag had a trailing slash (which, while incorrect, is
subsequently ignored by the brower) and the form is named "CatXML".

Poor pathetic Pavel. :-(
Jan 30 '07 #5

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

Similar topics

8
17309
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to change this field is some of the forms have two buttons on them, each needs to process the form differently. If I can change the value of the hidden field dynamically it will solve my issue as I can run each against a diffent cgi. Currently my...
4
10932
by: Wim Roffal | last post by:
Is it possible to use javascript to change the name of a field in a form? Thanks, Wim
2
12876
by: juglesh | last post by:
hi, all, thanks for reading. i have a form in which i want drop down boxes to dynamically change some hidden fields: http://cynthialoganjewelry.com/test4.htm <form name=test method="post" > Pearl Color: <select name="product1">
2
2861
by: Cady | last post by:
I'm trying to do an automatic signup for a newsletter hosted on a separate site. The original page is to sign up to receive a catalog by mail, with an option to signup for an e-newsletter. All of the information is validated when the user clicks submit. At this point a second page is opened (thanking them for their request) and the information previously entered is hidden in a form to be submitted to the e-newsletter service provider....
5
4396
by: John Oliver | last post by:
I'd like the email produced by FormMail to show a specific From: address rather than postmaster@server.host.name Googling isn't helping me... not sure what to look for :-( -- * John Oliver http://www.john-oliver.net/ * * California gun owners - protect your rights and join the CRPA today! * * http://www.crpa.org/ * * San Diego shooters come to...
1
3611
by: norman29 | last post by:
Hi all! How can i do this: <form method="get" action="test.asp" > <input name="boys" type=radio value="John">John <input name="boys" type=radio value="Lu">Lu <input name="boys" type=radio value="James">James <input name="student" type=checkbox value="yes">student? and now: if student=yes then this boy is a student:
2
2197
cassbiz
by: cassbiz | last post by:
I may be in the wrong forum so Ronald don't shoot :) In my code I have an option box to choose a number - works fine. I want to carry over the new value to another field to do a recalculation. Primarily the field "$preis1" to change with the javascript. Here is the code. <script type="text/javascript">
2
3266
by: pozitronic | last post by:
Hey all, I would like to do the following: I have 3 radio boxes. <input name="br" type="radio" value="first">Button1<br> <input name="br" type="radio" value="second">Button2<br> <input name="br" type="radio" value="third" />Button3<br>
5
4471
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know if I have the entirely wrong approach, but my code is below. Any or all help is appreciated! What currently happens is that the getdivision.php script works perfectly and gives me an entire table of correct data. The problem is that when I click...
0
9781
marktang
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...
0
10769
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
10477
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...
1
10522
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,...
0
10197
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...
1
7740
isladogs
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...
0
6944
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();...
2
3956
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3072
bsmnconsultancy
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...

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.