Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Form Values

  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Values

    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

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?"]
    Last edited by cheesebagpipe; 06-07-2003 at 04:18 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •