473,772 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating a form element in a function?

Hello,

I have a form that I want to submit "onchange", OK I've got that working, but when the
form submits, I want to pass along a value to a CGI script, as if that value was in a
hidden form element.

BUT, I don't want that value to be in the actual HTML form, I want it to be created in my
submit function.

For instance:
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!--
  3. function submit_this() {
  4.  
  5. // right here I would define a name value pair to send
  6. var go_update = 'true';
  7.  
  8. // now I want to send this along with the form data
  9. document.form_name.submit();
  10. }
  11. //-->
  12. </script>
  13.  
Any suggestions on how I might do this?
Do I need to define a form element in my function?
I can't find anything on this.

Thanks,

dstefani
Jul 23 '05 #1
1 1982
In article <dy************ *******@newssvr 29.news.prodigy .com>,
Don Stefani <no********@yah oo.com> wrote:
Hello,

I have a form that I want to submit "onchange", OK I've got that working, but
when the
form submits, I want to pass along a value to a CGI script, as if that value
was in a
hidden form element.

BUT, I don't want that value to be in the actual HTML form, I want it to be
created in my
submit function.

Please explain why a hidden field will not work for you.

If a field is not null, the field data will be sent to the host. Null
fields are not sent to the host. How can a hidden field cause you
problems?

You could create the hidden field dynamically, but a static hidden field
seems easier.

Here is a post about creating dynamic form fields
Re: How to expand the number of fields in a form? :
http://groups.google.com/groups?q=ma...group:comp.lan
g.javascript&hl =en&lr=&ie=UTF-8&oe=ISO-8859-1&selm=MPG.1af1 b944853eff5498
9da2%40nntp.luc ent.com&rnum=1

Here is an example using a static hidden field:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>A sample form</title>

<SCRIPT type="text/javascript">
function changeForm()
{
document.forms[0].the_current.va lue = "filled with data";
alert("form input value = " +
document.forms[0].hours.value +
" hidden value = " +
document.forms[0].the_current.va lue);
}
</script>

</head>
<body>
<form action=
"http://www.mindspring. com/cgi-bin/cgiemail"
method="post" name="payroll"
onSubmit="chang eForm()">
<input type="hidden" name="the_curre nt" value="">

<b>How many hours did you work this week?&nbsp&nbsp </b>
<input type="text" name="hours" size="6" maxlength="3">< br>

<input type="submit" name="submit" value="Process form">&nbsp&nbs p
<br>
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>

Please note that I have not verified that the the field data was sent to
the host.

Robert
Jul 23 '05 #2

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

Similar topics

6
2737
by: gonzalo briceno | last post by:
I have been using phplib for a while and I really like the framework except for form creation. Maybe it is me but I in my opinion there isn't a good way to create forms or should I say, everything else is so well done that the way you create forms seems to be too cumbersome, in particular making it so that a pull down menu selects a value that you assign it. In any case, does anyone know of any php based (or other readily accepted web...
72
5239
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to complete in connection with attendance at a seminar. After spending more than 15 minutes on it, I clicked on the submit button - and nothing happened. Looking round the pages on Javascript form validation that Google produced for me (well,...
12
2471
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" HTML----------- Form is ----> <form action="thanks.php" method="post" name="contact_form" id="contact_form"> Name -------> <input type="text" name="name" id="name" size="25"> Button sends code -----> <input type="button" value="Submit Form"
3
2875
by: Skippytpe | last post by:
Does anyone have an idea why the form validation in the following page wouldn't be working? I had been using XHTML 1.0 transitional which allowed me to use the form attribute 'name.' I could then just point the regular expression test to document.login.frmEmployeeNumber.value and have it validate. Now that I'm at XHTML 1.1 strict, I can only use form id's so I *thought* I could pull the elements out as I have below, but it's not...
2
4199
by: pshvarts | last post by:
(I'm new in SOAP) I get some wsdl file (from apache service ). I tried creating SOAP client with .NET - trying to add Web Reference and get error like: "Custom tool error: Unable to import WebService/Schema. Unable to import binding..." I thought may be wsdl file is not good enough (it was created with qsoap toolkit), so I paste-copy sample from http://www.w3.org/TR/2001/NOTE-wsdl-20010315#_wsdl (will paste below) and receive same error...
4
7267
by: jedimasta | last post by:
Good evening all, I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm using an include to pull in form elements (text fields, checkboxes, etc...) multiple times on a single page. The included page does not have a form tag of it's own, but the root page has uniquely named forms for validation. Imagine it like this:
9
1567
by: whisher | last post by:
Hi. I've managed this simple snippet: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Register</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script language="JavaScript" type="text/JavaScript"> var usernameError = 'Invalid String username';
1
10826
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I have defined the relavant function method in the code for details) The issue is that when Icall targetForm._submit() method from the newSubmit() function the page I get an 'Object doesn't support this property or method' error I am using IE...
2
3330
by: yomadhu | last post by:
I created a dynamic form in javascript. Am unable to get those values in to php to display. I need all details. If i add 10 rows the i need to display those all values. Can any one help me for that code. <HTML> <HEAD> <TITLE> Add/Remove dynamic rows in HTML table </TITLE> <script type="text/javascript" src="script.js"> // JavaScript Document var c=0;
0
9621
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
10264
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...
1
10039
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
9914
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
8937
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
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
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
3
2851
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.