I'm having a strange issue with a form I'm developing. I'm saving some values to hidden fields when a user clicks a button. I setup a function which gets ran on submission of the form, but I also placed this function on my submission button when clicked. -
<input name="button5" type="button" class="Buttons" id="button5" value="On File" OnClick="setup_req('cpr_onfile',1);"/>
-
<input type="hidden" name="cert_onfile"/>
-
-
.....
-
-
<cfform action="submit.cfm" method="post" name="perf_form" id="perf_form" onsubmit="return form_submission(); return false;">
-
-
....
-
-
<input type="submit" name="button13" id="button13" value="Submit" class="Buttons" onClick="return form_submission();return false;"/>
-
-
function setup_req(req,val){
-
//This function saves the data when the user selects "On File" or "NA"
-
req_ele=document.getElementsByName(req)
-
req_ele.value=val
-
}
-
-
function form_submission(){
-
alert("Validating Fields")
-
var testing = document.getElementsByName('cert_onfile')
-
alert(testing.value)
-
alert(testing)
-
return true;
-
}
-
When the alert pops up when the submission button is selected, I can see the value of the hidden field. When the alert pops up when the form submission calls the "form_submissio n" function, the hidden field is undefined.
What could be happening when the form submission takes place that's erasing my hidden fields?
5 7345
Nevermind, I should be using getElementById rather than getElementsByNa me
acoder 16,027
Recognized Expert Moderator MVP
Even if you do, if you've not set the ID, it's not going to work.
Even if you do, if you've not set the ID, it's not going to work.
I set the ID and used getElementById( ) and it worked like a charm.
acoder 16,027
Recognized Expert Moderator MVP
A couple of points: - You could've use document.getEle mentsByTagName like this:
- document.getElementsByName("cert_onfile")[0]
assuming that was the only element named "cert_onfil e" or the first one. Having said that, it's better to use a unique ID. - There's no need to return false in the onclick/onsubmit since you're already returning with form_submission ().
A couple of points:- You could've use document.getEle mentsByTagName like this:
- document.getElementsByName("cert_onfile")[0]
assuming that was the only element named "cert_onfil e" or the first one. Having said that, it's better to use a unique ID. - There's no need to return false in the onclick/onsubmit since you're already returning with form_submission ().
Thanks for those tips acoder, I'll keep them in mind. I had a feeling I didn't need the return false in my onsubmit. I'm still learning javascript, but it's coming along.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dan R Brown |
last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to
break up this form into several "tabbed" sections, I break up the form using <div>
tags. Each <div style="display:none"> can be displayed by setting the style attribute
to "display:", or hidden with "display:none". This gives the illusion that the person
filling out the form is switching from page to page...without the overhead of extra
hits on the server,...
|
by: Paul Morrow |
last post by:
I have seen the technique where a number of rows in a database are
displayed in an html table so that each column of each row is
editable. They use a single form surrounding the table, where each
field in any given column has the same control name. So for example,
in the last_name column, every row in the table would contain an input
field (of type "text") with the name "last_name".
Is this safe to do? I know that multiple radio...
|
by: Fred |
last post by:
Hi,
i know how to pass a value from Javascript to ASP with a hidden field into a
form and submitting it, or with cookies, but here i have to pass a lot of
data in an array.
There is a list of product the visitor can order by clicking one or more
checkboxes. I made a form containing input with type "checkbox" like:
<form>
<input type="checkbox" name=ck id=ck
|
by: Itai |
last post by:
I have an aspx file named index.aspx which contains two ‘form'
sections, one that has the runat=server attribute (e.g From1) and one
which is a regular HTML form (e.g SignInForm).
I am trying to copy values from two INPUT controls that are located
within the Form1 section to hidden INPUT controls located in the
SignInForm and post the SignInForm form hidden controls values to a
different page (e.g login.aspx)
Problem is that after...
|
by: Randell D. |
last post by:
Folks,
I have a large amount of values to store (we're talking tens, if not
hundreds of bytes). I need this for a client side application - ignore
the security consequences for the moment - however my question is, which
is more performance effective, or easier on a clients resources?
I mean - if I have several <input type=hidden> tags with my values that
I can reference, would this have a greater overhead then, for example,
having an...
| |
by: GavMc |
last post by:
Hello I am new to internet programming and wonder if anyone can help me with
this....
I am trying to pass a hidden field value on a form into another field on the
form so that it can then be inserted in the database, to enable me then to
reference that number at a later date.
(The hidden value (1 for example) would then automatically get passed to the
other input field.)
|
by: Alan Silver |
last post by:
Hello,
I have a page that gets passed an ID in the query string. It then uses
this ID to pull info out of a database and populate controls on the
page. When the page is posted back, the query string is not going to be
there any more, so I need some way of storing the ID.
What's the best way of doing this? The obvious thought is a hidden form
field, but there doesn't seem to be a web control for this. Do I just
use an ordinary HTML...
|
by: Microsoft_Public |
last post by:
All I'm getting is <null>......
I have a legacy input form that I must maintain for a few more months until
the balance of the site can be converted to .Net.
I need the one database field to contain either 0, 1, 2.
The form has 2 pairs of radio button fields.
If the answer to the first Q is Yes value = 1
|
by: Ian Davies |
last post by:
Hello
I wish to use J.S. to obtain the screen ht and put this value into a hidden
field for posting. so that I can then use it in a php file.
A simplified script of what I am trying to do is below, but it doesnt work.
I have not used javascript much and I'm sure its straight forward.
<script type="text/javascript" language="javascript">
var ht = document.body.clientHeight;
</script>
|
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: 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...
|
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: 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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| | |