...

View Full Version : Form Values



gemynd
06-07-2003, 12:35 AM
I am trying to use multiple combo boxes to form a string of words describing something and then place that text string into a textbox. I have the following script...

function SubmitOrder(form) {
ExchangeForm.OrderQueue.value = ExchangeForm.OrderQueue.value+"Result: "+ExchangeForm.UnitOut.Value+ExchangeForm.UnitIn.Value+ExchangeForm.Quantity.Value+";";
Window.Close
}

...and the following form...

<FORM name=ExchangeForm>
<TABLE border="1" width="100%">
<TR>
<TD width="33%"><FONT size="1" face="Arial">Initial Units</FONT></TD>
<TD width="33%"><FONT size="1" face="Arial">Secondary Units</FONT></TD>
<TD width="34%"><FONT size="1" face="Arial">Quantity</FONT></TD>
</TR>
<TR>
<TD width="33%"><SELECT size="1" name=UnitOut style="font-size: 10px; background: black; color: white;">
<OPTION value="a" selected>Alpha</OPTION>
<OPTION value="b">Bravo</OPTION>
<OPTION value="c">Charlie</OPTION>
</SELECT></TD>
<TD width="33%"><SELECT size="1" name=UnitIn style="font-size: 10px; background: black; color: white;">
<OPTION value="a" selected>Alpha</OPTION>
<OPTION value="b">Bravo</OPTION>
<OPTION value="c">Charlie</OPTION>
</SELECT></TD>
<TD width="34%"><SELECT size="1" name=Quantity style="font-size: 10px; background: black; color: white;">
<OPTION selected>1</OPTION>
<OPTION>2</OPTION>
<OPTION>3</OPTION>
</SELECT></TD>
</TR>
</TABLE>
<P align="center"><INPUT type="button" value="Exchange" name=Exchange onclick="javascript:SubmitOrder(this.form)" style="font-size: 10px; background: black; color: white;">
</P>
</FORM>

...however, whenever I click the Exchange button, I get the following...

"Result: undefinedundefinedundefined"

...in the textbox. What does it mean when it states "Undefined"?

-Brian

Jason
06-07-2003, 12:46 AM
it means that something is undefined ;) but what you might want to do is instead of name=blah make it have quotes name="blah" so that would possibly better define the variable names...


Jason

cheesebagpipe
06-07-2003, 01:19 AM
Errors galore:

1) onclick="javascript&#58;

lose that javascript&#58;

2) function SubmitOrder(form) {
ExchangeForm.OrderQueue.value = ExchangeForm

Passed the Form object(SubmitOrder(this.form)) - good move - now you're ignoring it...

function SubmitOrder(form) {
form.OrderQueue.value = ExchangeForm

3) Here's how to get the value from a select, cross-browser:

Select.options[Select.selectedIndex].value

Might get it from just Select.value, might not...

4) Biggest problem: ExchangeForm.UnitOut.Value (etc.)

JS is case-sensitive (.value)

5) Window.Close // ?????

Easier:

ExchangeForm.OrderQueue.value += ......

'undefined' means 'I can't find that thingy...' ["hey, what's a 'Value', dude?"]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum