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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with on select change form destination

    Im trying to get my form to change to a certain configoration file depending on what country is selected.
    This is the first time Ive tried to write something like this from scratch.( most likely my last)
    it selects ok but if i try to select a different country it wont change the selection.
    can someone please point me in the right direction
    Thanks
    Dean
    <HTML>
    p></p>

    <p>&nbsp;</p>
    <p align="center">&nbsp;</p>
    <FORM NAME="myform" form method="POST" action="http://myserver.com" enctype="multipart/form-data">


    <INPUT TYPE=HIDDEN NAME="News_paper" VALUE="news limited">
    <div align="center" style="width: 470; height: 1062">


    <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" width="625">
    <tr>
    <td width="74"></td>
    <td width="299">
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="615" colspan="5" align="center"><tt><b><font color="#CC3333" face="Arial, Helvetica, sans-serif" size="6">News
    Limited</font></b></tt></td>
    <td width="615" align="center"></td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299">
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299">
    <h3 align="center"><b>News Details</b></h3>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Rep</font></td>
    <td width="299">
    <input type="text" name="Rep" size="20">

    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71">

    <p>&nbsp;</td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Source</font></td>
    <td width="299">
    <font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top"><input type="text" name="source" size="40"></a>
    </font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Description</font></td>
    <td width="299">
    <font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top"><input type="text" name="description" size="40">
    </a></font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299">
    <h3 align="center"><b>Card Details</b></h3>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Card Holder</font></td>
    <td width="299">
    <a name="Top"><input type="text" name="card_holder" size="40"></a>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Card Type</font></td>
    <td width="299">
    <font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top"><input type="text" name="card_type" size="40">
    </a></font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Card Number</font></td>
    <td width="299">
    <font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top"><input type="text" name="card_number" size="40">
    </font>

    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">Expiry</font></td>
    <td width="299">
    <font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top"><input type="text" name="expiry" size="6">
    </a></font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299">
    <h3 align="center">Customer Details</h3>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">First Name</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top"><input type="text" name="first_name" size="40">
    </a></font></td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">Last Name</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f><a name="Top">
    <input type="text" name="last_name" size="40">
    </a></font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">Address</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f>
    <input type="text" name="Address" size="40">
    </font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">Suburb</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f>
    <input type="text" name="Suburb" size="40">
    </font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">State</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f><input type="text" name="State" size="40">

    </font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">Post Code</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f><input type="text" name="PostCode" size="40" >

    </font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">Country</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f> <input
    type="text" onBlur="theresponse" name="configorationfile" size="35">
    </font>
    <select
    name="theresponse" size="1" onBlur="responses()"><option value=""></option><option value="Australia">Australia</option><option value="Albania">Albania</option><option value="Algeria">Algeria</option><option value="American Samoa">American
    Samoa</option><option value="Andorra">Andorra</option><option value="Anguilla">Anguilla</option><option value="Antigua">Antigua</option><option value="Argentina">Argentina</option><option value="Aruba">Aruba</option><option value="Australia" selected>Australia</option><option value="Austria">Austria</option><option value="Azores">Azores</option>option value="United Kingdom">United
    Kingdom</option><option value="United States">United States</option><option value="Uruguay">Uruguay</option><option value="Uzbekistan">Uzbekistan</option><option value="Vanuatu">Vanuatu</option><option value="Venezuela">Venezuela</option><option value="Vietnam">Vietnam</option><option value="Virgin Gorda">Virgin
    Gorda</option><option value="Wake Island">Wake Island</option><option value="Wales">Wales</option><option value="Wallis and Futuna Islands">Wallis
    and Futuna Islands</option><option value="Western Samoa">Western Samoa</option><option value="Yap">Yap</option><option value="Yemen">Yemen</option><option value="Zaire">Zaire</option><option value="Zambia">Zambia</option><option value="Zimbabwe">Zimbabwe</option><font face="Arial,Helvetica" size=1>&nbsp;</font>
    </select>

    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" nowrap><font color="#FFFFFF">Phone</font></td>
    <td width="299"><font face="Times New Roman, Times, serif" size="2" color=#000000f><input type="text" name="Phone" size="40">

    </font>
    </td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299"></td>
    <td width="246" colspan="3">
    <p align="center"></td>
    <td width="246">
    </td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299"></td>
    <td width="91" align="center"><font color="#FFFFFF">6x8</font></td>
    <td width="80" align="center"><font color="#FFFFFF">8x12</font></td>
    <td width="71" align="center"><font color="#FFFFFF">12x18</font></td>
    <td width="71" align="center"></td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 1</font></td>
    <td width="299">
    <input type="file" name="FILE01" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_1_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_1_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_1_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center">
    </td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 2</font></td>
    <td width="299">
    <input type="file" name="FILE02" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_2_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_2_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_2_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center"><
    </td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 3</font></td>
    <td width="299">
    <input type="file" name="FILE03" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_3_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_3_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_3_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center">
    </td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 4</font></td>
    <td width="299">
    <input type="file" name="FILE04" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_4_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_4_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_4_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 5</font></td>
    <td width="299">
    <input type="file" name="FILE05" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_5_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_5_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_5_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center">
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 8</font></td>
    <td width="299">
    <input type="file" name="FILE08" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_8_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_8_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_8_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 9</font></td>
    <td width="299">
    <input type="file" name="FILE09" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_9_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_9_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_9_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center
    </td>
    </tr>
    <tr>
    <td width="74"><font color="#FFFFFF">File 10</font></td>
    <td width="299">
    <input type="file" name="FILE10" size="30"> </td>
    <td width="91" align="center"> <input type="text" name="File_10_6x8" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,17.50);"></td>
    <td width="80" align="center"><input type="text" name="File_10_8x12" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,35.00);"></td>
    <td width="71" align="center"><input type="text" name="File_10_12x18" size="6" value="0" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,90.00);">
    </td>
    <td width="71" align="center"><select size="1"
    </td>
    </tr>
    <tr>
    <td width="74"></td>
    <td width="299"><textarea rows="2" name="comments" cols="30">Special Instructions</textarea></td>
    <td width="91"></td>
    <td width="80"></td>
    <td width="71"></td>
    <td width="71"></td>
    </tr>
    <tr>
    <td width="74" height="89" valign="top">
    </td>
    <td width="547" height="89" colspan="4">
    <font color="#FFFFFF">
    <p><input type="checkbox" name="Approval[]1" value="2" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,0.00);">Standard
    Post</p>
    <p><input type="checkbox" name="Approval[]" value="4" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,1.25);">Express Post
    </font>
    <p><font color="#FFFFFF"><input type="checkbox" name=remove value="1" onChange="this.form.total.value=checkChoice(this);" onFocus="setInput(this,-5.00);">Remove Express Post fee</font>
    </font>
    </td>
    <td width="547" height="89">
    </td>
    </tr>
    <tr>

    <td width="74" height="25" valign="top">
    </td>
    <td width="547" height="25" colspan="4">
    <p align="right">
    <font color="#FFFFFF">
    &nbsp; <input type=hidden name=hiddentotal value=0>
    Total being charged to Customer:&nbsp;&nbsp; <input type="text" name="total" value="0.00" size=8
    onBlur="this.value = formatCurrency(hiddentotal.value);">
    </font>
    </p>
    </td>
    <td width="547" height="25">
    </td>
    </tr>
    <tr>
    <td height="1" width="74"></td>
    <td width="547" height="1" colspan="4">
    <input type="submit" value="Send" name="submit"onClick="confirm('If you wish to stop this order click CANCEL then click your browsers STOP button. If you wish the order to go through click OK')">
    <input type="reset" name="Reset" value="Clear">
    &nbsp;<font color="#FFFFFF">Please be patient. This can take a while.</font><br>
    </td>
    <td width="547" height="1">
    </td>
    </tr>
    </table>
    </center>
    </div>
    </form>
    <p>&nbsp;</p>
    </form>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </script>
    <script language="JavaScript1.1">
    function responses()
    {if(document.myform.theresponse.value="Australia")(document.myform.configorationfile.value="aus_samp le.php3")}
    {if (document.myform.theresponse.value="United States")(document.myform.configorationfile.value="usa_sample.php3")}


    </script>

    </BODY>
    </HTML>

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    OK. This:

    function responses()
    {if(document.myform.theresponse.value="Australia")(document.myform.configorationfile.value="aus_samp le.php3")}
    {if (document.myform.theresponse.value="United States")(document.myform.configorationfile.value="usa_sample.php3")}


    Needs to look like this:

    function responses(){
    if(document.myform.theresponse.value="Australia"){
    document.myform.configorationfile.value="aus_sample.php3"
    }
    if(document.myform.theresponse.value="United States"){
    document.myform.configorationfile.value="usa_sample.php3"
    }
    }

    This:

    <FORM NAME="myform" form method="POST" action="http://myserver.com" enctype="multipart/form-data">

    should probably look like this:

    <FORM NAME="myform" method="POST" action="http://myserver.com">

    (you only need that enctype attribute if you're submitting files - apologies if I missed one)

    This:

    <select name="theresponse" size="1" onBlur="responses()">

    would be better served by this:

    <select name="theresponse" size="1" onChange="responses()">



    Also:

    </form>
    <p> </p>
    </form>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    </script>

    One form inside another isn't going to help, stacks of empty <p> tags are bad practice and I'm not sure where that <script> tag came from.


    To summarise: run your code through a validator.

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Everyone on this board can identify with this:
    This is the first time Ive tried to write something like this from scratch.( most likely my last)
    lol...don't give up so easily, it gets better...or worse ...anyhow:
    Code:
    <select name="theresponse" size="1" onchange="return responses(this)"><!-- pass select object -->
    ..............
    ..............
    function responses(oSelect) { //get select object
         var oForm = oSelect.form; //get form object
         var selval = oSelect.options[oSelect.selectedIndex].value; //get selected value
         if (selval == 'Australia')
             oForm.configorationfile.value = 'aus_sample.php3';
         else if (selval == 'United States') 
             oForm.configorationfile.value = 'usa_sample.php3';
         return true;
    }
    It's always easier to pass the object - actually it's a reference to the object - than jumping from the object (Select) over to a function and having to find your way back immediately, using the element name, etc. All form elements have a .form property which references the containing Form object. Your principal error is indicated in red, and very common: using the assignment operator - setting something equal to something (single equals sign), when you needed to use the comparison operator (double equal signs) to generate a Boolean value (true/false) depending on the result of the comparison. That's why the select seemed 'locked' - the function always reset the Select.value. The more involved way of getting the selected value gives a bit better (older) browser coverage.

    Not a clue on this one:

    <input
    type="text" onBlur="theresponse" name="configorationfile" size="35">

    Messy HTML! Hang in there...

    cbp

  • #4
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Thanks cheesebagpipe
    got it working exactly the way I wanted it.
    Your help is much appreciated
    Dean


  •  

    Posting Permissions

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