473,325 Members | 2,671 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,325 software developers and data experts.

Changing a hidden field

I have what is probably a very simple question, but I am VERY new to
javascript. Here is what I want to accomplish.

I have a text box called zp. I also have a hidden field called frm.
There is also a submit button.

When the submit button is pressed, I want to set the value of the
hidden field, frm, depending upon whether or not there the text field,
zp, is empty. For example, if it is empty I want the hidden field to
be frm="empty" and if there is something there I want it to be
frm="set".

These fields are in inside a form of method "GET" with an action of a
URL. The hidden fields are passed to the new page automatically as
properties at the end of the URL string with the ? and the &. The
action taken in the new page depends upon the value of frm that is
passed.

Would I add an onclick to the submit button or an onexit to the text
box, zp? How to I name the variable? Is it document.frm?

As I said, I am a real beginner here.

Shelly

Apr 28 '06 #1
2 1710
brk
Hi Shelly,
Here is the code

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function onSub()
{
if(document.forms[0].zp != null && document.forms[0].zp.value != '')
document.forms[0].frm.value = "set"
else
document.forms[0].frm.value = "empty"
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<FORM METHOD=GET ACTION="" onsubmit="return onSub()">
<INPUT TYPE="text" NAME="zp">
<INPUT TYPE="hidden" name="frm">
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>

Apr 28 '06 #2
Thank you very much. While waiting for this answer, it dawned on me to
go a location that does this and to look at THAT javascript via view
source. I adapted that script and it works. It is issentially what
you wrote here. Thanks again.

Apr 28 '06 #3

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
1
by: George Rogic | last post by:
Hello: I've done an exhaustive online search and either can't find what I'm looking for or I'm unable to make what I've found work. I'm not a programmer, but I'm sure that this is probably...
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
4
by: multimatum2 | last post by:
Hello, I need to enable/disable input text forms... But... I need to have the same style (color...) in both modes.. Could you help me ? Thanx a lot A small sample... ...
8
by: Ryan | last post by:
I have a hidden field as such: <INPUT TYPE=\"hidden\" name=xmlfield > I have a button that i want to use to call a function to change the value: <INPUT TYPE=submit VALUE="Display XML"...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
6
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
3
by: Kevin Gorski | last post by:
This question has been asked before, but there have been no definitive answers that I was able to find. Can the viewstate hidden input field be moved to a less prominent page location? On an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.