dcsimg
www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24

Thread: Radio Buttons with "other" Text input option

  1. #16
    Join Date
    Dec 2012
    Posts
    1,191
    Please read my previous posting: You need to add the id "rbother" to the radio button for other country:
    HTML Code:
    <label><input id="rbother" type="radio" name="OPS" value=" " /> Other Country
    If you don't get it working, please put it online including the script.

  2. #17
    Join Date
    Mar 2017
    Posts
    12
    That's returning the correct values for all the radio buttons, but blank with Other Country button selected and any typed in entry.
    The source code is this (if you use view page source - easier than pasting here): http://www.bellowsfallsalumni.org/Update.html
    and the PHP script is here: http://www.bellowsfallsalumni.org/mailer.txt (saved as a txt file but there on the server as mailer.php.

  3. #18
    Join Date
    Dec 2005
    Location
    TX
    Posts
    7,750
    You may have some problems here:
    1. Line 71: otherCountryText is null
    2. Lines 225-227: <label> tags encompass two (2) input elements
    3. Line 64: using document.write after the page has been rendered causes program to reset to the ORIGINALLY loaded elements, NOT the user changed values

    May be other errors, but those should be fixed to allow script to function successfully.

  4. #19
    Join Date
    Dec 2012
    Posts
    1,191
    The script is missing: "rbothers" is referenced nowhere. You need to mirror the content of the text input to the value of the radio button.

  5. #20
    Join Date
    Mar 2017
    Posts
    12
    Thank you JMRKER!
    I too wondered about line 71 but copied the code suggested by another forum user and I'm not all that JavaScript literate so thought it was OK as was. Will try to figure out what it was supposed to do and how to fit it in if still needed.
    I'll try some label variations (line 225 only, line 226 only, or both but not joined as they are).
    I'll research some variations on the document.write. Thought it was there to reset if the user clicked on one radio button and then decided to use a different one, especially if the text field was chosen and then a radio button was chosen before submitting.
    Thanks for bearing with me on this. As I mentioned earlier, I thought this routine of 4 radio buttons with a 5th "other entry" would not be nearly so complex and convoluted as it appears to be. So much from what I learned playing around with Assembly . . .
    Thanks again!

  6. #21
    Join Date
    Dec 2005
    Location
    TX
    Posts
    7,750
    I'm still confused as to what it is that you are having problems with.

    In post #13 I provided code that isolated only on the 'Country' problem.

    Have you run it?
    What specifically does it NOT do that you requested to be done?

  7. #22
    Join Date
    Dec 2012
    Posts
    1,191
    IMO this in not complex. I prepared a working demo here:
    http://ulrichbangert.de/div/webentwi.../php/form.html
    Give it a try.
    The only thing I changed was this:
    Code:
                <input id="rbother" type="radio" name="OPS" value=" "> Other Country
                <input id="inputother"type="text" name="" value="" maxlength="60" size="35" onchange="setCountry(this)">
                <script type="text/javascript">
                    function setCountry(ele) {
                        document.getElementById("rbother").value = ele.value;
                    }
                </script>

  8. #23
    Join Date
    Mar 2017
    Posts
    12
    Excuse my language but . . . Holy **** that works!
    Thank you Sempervivum!!!!
    You have saved what little sanity I have left at this point! Thank you! (Y)

  9. #24
    Join Date
    Mar 2017
    Posts
    12
    Thank you for your help, JMRKER!
    It looks like I finally have it working using the code snippet that Sempervivum provided (@4:09, msg #22).
    I haven't taken out the line @ 71 nor the line @ 64 - yet, but will see if it all works with them "out of the picture"
    I tend on one hand to say if it ain't broke, don't fix it; while on the other wanting it to be clean of left-over spaghetti.
    Thanks again for your help with this - I have much to learn and your help is much appreciated!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles