473,396 Members | 1,929 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,396 software developers and data experts.

Javascript two fields merged to one hidden field


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
then add the result of the 2 pairs of input options
is assigned to the "Hidden" input field.

If the first ans is No value = 0
and that value is assigned to the "Hidden" input field.

..... snipit, code omitted....

&& validReplace(document.forms[0].APPLICANT_EXIST_INSUR,
document.forms[0].APPLICANT_REPLACE_INPUT);
}
..... code omitted....
function validReplace(formField1, formField2)
{
var existIns = formField1.value;
var replace = formField2.value;
if(existIns = "0") {
APPLICANT_REPLACE.value == existIns;
} else {
APPLICANT_REPLACE.value == (existIns ++ replace);
}
return APPLICANT_REPLACE;
}

...... code omited....

<td>Do you have existing insurance policies?</td>
<td align=right valign=top>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td valign=middle><input type="radio"
name="APPLICANT_EXIST_INSUR" value="1"></td><td>Yes &nbsp;</td>
<td><input type="radio" name="APPLICANT_EXIST_INSUR"
value="0"></td><td>No &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr><td colspan=2 bgcolor=#000000><img src="images/clear.gif"
height=1 border=0></td></tr>
<tr>
<td>Are you planning on replacing any insurance policies?</td>
<td align=right valign=top>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td valign=middle><input type="radio"
name="APPLICANT_REPLACE_INPUT" value="1"></td><td>Yes &nbsp;</td>
<td><input type="radio" name="APPLICANT_REPLACE_INPUT"
value="0"></td><td>No &nbsp;</td>
</tr>
</table>
<input type="hidden" name="APPLICANT_REPLACE" value="">
</td>

Dec 12 '05 #1
3 1468
I don't know if it's just the tool u used to post but...

ur using assignment operators (=) when you should be using equality
operators (==) and I have no idea what ++ is supposed to mean.

Is validReplace supposed to return true/false, or is it supposed to return
the value to put in the hidden form field, or both?

function validReplace(formField1, formField2)
{
var applicationReplace = document.forms[0].APPLICANT_REPLACE;
var existIns = formField1.value;
var replace = formField2.value;

if(existIns == "0") {
applicationReplace.value = existIns;
return false; //maybe you want to return true here, don't really
follow ur return logic...
//maybe you simply want to return applicationReplace
}
//no need for an else, if the above IF was true, you returned in there
and would never get here
applicationReplace.value = existIns + replace;
return true; //again figure out what you want to return
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Microsoft_Public" <No*********@sbcglobal.net> wrote in message
news:eI**************@TK2MSFTNGP14.phx.gbl...

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
then add the result of the 2 pairs of input options
is assigned to the "Hidden" input field.

If the first ans is No value = 0
and that value is assigned to the "Hidden" input field.

.... snipit, code omitted....

&& validReplace(document.forms[0].APPLICANT_EXIST_INSUR,
document.forms[0].APPLICANT_REPLACE_INPUT);
}
.... code omitted....
function validReplace(formField1, formField2)
{
var existIns = formField1.value;
var replace = formField2.value;
if(existIns = "0") {
APPLICANT_REPLACE.value == existIns;
} else {
APPLICANT_REPLACE.value == (existIns ++ replace);
}
return APPLICANT_REPLACE;
}

..... code omited....

<td>Do you have existing insurance policies?</td>
<td align=right valign=top>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td valign=middle><input type="radio"
name="APPLICANT_EXIST_INSUR" value="1"></td><td>Yes &nbsp;</td>
<td><input type="radio" name="APPLICANT_EXIST_INSUR"
value="0"></td><td>No &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr><td colspan=2 bgcolor=#000000><img src="images/clear.gif"
height=1 border=0></td></tr>
<tr>
<td>Are you planning on replacing any insurance policies?</td>
<td align=right valign=top>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td valign=middle><input type="radio"
name="APPLICANT_REPLACE_INPUT" value="1"></td><td>Yes &nbsp;</td>
<td><input type="radio" name="APPLICANT_REPLACE_INPUT"
value="0"></td><td>No &nbsp;</td>
</tr>
</table>
<input type="hidden" name="APPLICANT_REPLACE" value="">
</td>

Dec 12 '05 #2
JDP
I'm sorry I wasn't perfectly clear, my ++ was my "attempt" to add the values as
integers.

If the value of the first question is 1 (yes) then add that to the value of the
2nd question,
either 1 + 0 = 1, or 1 + 1 = 2, however it occurs to me that I should set the
2nd value if it's empty (null).

If the value of the 2nd question is 1, I don't want to add that to the first
question as,
0 + 1 = 1 that would be bad, logicially you can't replace what you don't have,
see below.....

In my db, 0 = no existing ins, and not replacing, and a 1 = existing insurance,
2 means existing insurance and replacing.

TIA

JeffP.....

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:e4**************@TK2MSFTNGP14.phx.gbl...
I don't know if it's just the tool u used to post but...

ur using assignment operators (=) when you should be using equality
operators (==) and I have no idea what ++ is supposed to mean.

Is validReplace supposed to return true/false, or is it supposed to return
the value to put in the hidden form field, or both?

function validReplace(formField1, formField2)
{
var applicationReplace = document.forms[0].APPLICANT_REPLACE;
var existIns = formField1.value;
var replace = formField2.value;

if(existIns == "0") {
applicationReplace.value = existIns;
return false; //maybe you want to return true here, don't really
follow ur return logic...
//maybe you simply want to return applicationReplace
}
//no need for an else, if the above IF was true, you returned in there
and would never get here
applicationReplace.value = existIns + replace;
return true; //again figure out what you want to return
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Microsoft_Public" <No*********@sbcglobal.net> wrote in message
news:eI**************@TK2MSFTNGP14.phx.gbl...

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
then add the result of the 2 pairs of input options
is assigned to the "Hidden" input field.

If the first ans is No value = 0
and that value is assigned to the "Hidden" input field.

.... snipit, code omitted....

&& validReplace(document.forms[0].APPLICANT_EXIST_INSUR,
document.forms[0].APPLICANT_REPLACE_INPUT);
}
.... code omitted....
function validReplace(formField1, formField2)
{
var existIns = formField1.value;
var replace = formField2.value;
if(existIns = "0") {
APPLICANT_REPLACE.value == existIns;
} else {
APPLICANT_REPLACE.value == (existIns ++ replace);
}
return APPLICANT_REPLACE;
}

..... code omited....

<td>Do you have existing insurance policies?</td>
<td align=right valign=top>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td valign=middle><input type="radio"
name="APPLICANT_EXIST_INSUR" value="1"></td><td>Yes &nbsp;</td>
<td><input type="radio" name="APPLICANT_EXIST_INSUR"
value="0"></td><td>No &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr><td colspan=2 bgcolor=#000000><img src="images/clear.gif"
height=1 border=0></td></tr>
<tr>
<td>Are you planning on replacing any insurance policies?</td>
<td align=right valign=top>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td valign=middle><input type="radio"
name="APPLICANT_REPLACE_INPUT" value="1"></td><td>Yes &nbsp;</td>
<td><input type="radio" name="APPLICANT_REPLACE_INPUT"
value="0"></td><td>No &nbsp;</td>
</tr>
</table>
<input type="hidden" name="APPLICANT_REPLACE" value="">
</td>


Dec 14 '05 #3
0 = no existing insurance, not replacing
1 = existing insurance
2 = existing insurance and replacing

and there's no case for no insurance and replacing I guess...that simply
isn't valid?
Seems to me the simplest way to do this and to simply code the logic as we
describe. Why add things together when our rules are so simple?

var existingInsurnace = parseInt(formField1.value);
var replacing = parseInt(formField2.value);

if (existingInsurance == 1 && replacing == 1)
{
value = 2; //existing insurance and replacing
}
else if (existingInsurance == 1)
{
value = 1; existing insurance
}
else
{
value = 0; neither
}

it might not be magical, but it's awfully straightforward and self-evident.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"JDP@Work" <JP*********@sbcglobal.net> wrote in message
news:ec*************@TK2MSFTNGP15.phx.gbl...
I'm sorry I wasn't perfectly clear, my ++ was my "attempt" to add the
values as
integers.

If the value of the first question is 1 (yes) then add that to the value
of the
2nd question,
either 1 + 0 = 1, or 1 + 1 = 2, however it occurs to me that I should set
the
2nd value if it's empty (null).

If the value of the 2nd question is 1, I don't want to add that to the
first
question as,
0 + 1 = 1 that would be bad, logicially you can't replace what you don't
have,
see below.....

In my db, 0 = no existing ins, and not replacing, and a 1 = existing
insurance,
2 means existing insurance and replacing.

TIA

JeffP.....

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in
message news:e4**************@TK2MSFTNGP14.phx.gbl...
I don't know if it's just the tool u used to post but...

ur using assignment operators (=) when you should be using equality
operators (==) and I have no idea what ++ is supposed to mean.

Is validReplace supposed to return true/false, or is it supposed to
return
the value to put in the hidden form field, or both?

function validReplace(formField1, formField2)
{
var applicationReplace = document.forms[0].APPLICANT_REPLACE;
var existIns = formField1.value;
var replace = formField2.value;

if(existIns == "0") {
applicationReplace.value = existIns;
return false; //maybe you want to return true here, don't really
follow ur return logic...
//maybe you simply want to return applicationReplace
}
//no need for an else, if the above IF was true, you returned in there
and would never get here
applicationReplace.value = existIns + replace;
return true; //again figure out what you want to return
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Microsoft_Public" <No*********@sbcglobal.net> wrote in message
news:eI**************@TK2MSFTNGP14.phx.gbl...
>
> 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
> then add the result of the 2 pairs of input options
> is assigned to the "Hidden" input field.
>
> If the first ans is No value = 0
> and that value is assigned to the "Hidden" input field.
>
> .... snipit, code omitted....
>
> && validReplace(document.forms[0].APPLICANT_EXIST_INSUR,
> document.forms[0].APPLICANT_REPLACE_INPUT);
> }
> .... code omitted....
> function validReplace(formField1, formField2)
> {
> var existIns = formField1.value;
> var replace = formField2.value;
> if(existIns = "0") {
> APPLICANT_REPLACE.value == existIns;
> } else {
> APPLICANT_REPLACE.value == (existIns ++ replace);
> }
> return APPLICANT_REPLACE;
> }
>
> ..... code omited....
>
> <td>Do you have existing insurance policies?</td>
> <td align=right valign=top>
> <table border=0 cellspacing="0" cellpadding="0">
> <tr>
> <td valign=middle><input type="radio"
> name="APPLICANT_EXIST_INSUR" value="1"></td><td>Yes &nbsp;</td>
> <td><input type="radio" name="APPLICANT_EXIST_INSUR"
> value="0"></td><td>No &nbsp;</td>
> </tr>
> </table>
> </td>
> </tr>
> <tr><td colspan=2 bgcolor=#000000><img src="images/clear.gif"
> height=1 border=0></td></tr>
> <tr>
> <td>Are you planning on replacing any insurance policies?</td>
> <td align=right valign=top>
> <table border=0 cellspacing="0" cellpadding="0">
> <tr>
> <td valign=middle><input type="radio"
> name="APPLICANT_REPLACE_INPUT" value="1"></td><td>Yes &nbsp;</td>
> <td><input type="radio" name="APPLICANT_REPLACE_INPUT"
> value="0"></td><td>No &nbsp;</td>
> </tr>
> </table>
> <input type="hidden" name="APPLICANT_REPLACE" value="">
> </td>
>
>
>



Dec 14 '05 #4

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

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: ND | last post by:
I need to create a separate field from 4 fields, "street address", "city", "State" and "zip code". For example, Street address - 100 Forest Street City - Seattle State - WA Zip - 05555 ...
7
by: Andy | last post by:
Hi, I have a complicated question that I'm hoping someone can help me out with. I have a webpage that contains a plug-in. This plug-in can communicate/pass data with the webpage that contains it...
4
by: Shawn Repphan | last post by:
I apoligize if this is out of scope with this group. I have a textbox that displays a current record number(xx of xxx). The user has the ability to enter their own number into this box and perform...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
6
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>'...
11
by: viki1967 | last post by:
Hidden field Hello my friends. This is a htm page that contains a form open in window popUp ( page daughter ). This form insert a value in the one hidden field called "tec", in other form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
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,...
0
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...
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,...
0
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,...

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.