Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7187167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:47:08+00:00 2026-05-28T18:47:08+00:00

I’m trying to disable the name text field in the form when Choose is

  • 0

I’m trying to disable the “name” text field in the form when “Choose” is selected in the drop down after the page loads (it’s disabled when the page loads) ie after I’ve chosen one of the other two options that disable or enable that field, when I return to “Choose” i’d like the same field to disable. I can’t see why the javascript I’ve written would prevent this from happening. Thanks!

        <script type="text/javascript">

    function clickclear(thisfield, defaulttext) {
        if (thisfield.value === defaulttext) {
            thisfield.value = "";
        }
    }

    function clickrecall(thisfield, defaulttext) {
        if (thisfield.value === "") {
            thisfield.value = defaulttext;
        }
    }

    function checkPickup() {

        if (form.os0.value != "Pickup from Toowong, Brisbane" ) {
            form.name.disabled = false; form.name.style.color = '#333';

        } else {

            form.name.disabled = true; form.name.style.color = '#CCC';
            /* Reset form values */
            form.name.value = "His/her name";
        }
    }
</script>

<script type="text/javascript">
    function validate(form) {

        var errmsg = "Oops, you're required to complete the following fields! \n";

        // Various other form validations here

        // Validate "Pickup"
        if (form.os0.value === "") {
            errmsg = errmsg + " - Choose pickup or delivery\n";
        }

        // Validate "phone"
        if (form.phone.value === "" || form.phone.value === "Mobile's best!") {
            errmsg = errmsg + " - Your phone number\n";
        }


        if (form.os0.value != "Pickup from Toowong, Brisbane") {

            // Validate "name"
            if (form.name.value === "" || form.name.value === "His/her name") {
                errmsg = errmsg + " - His/her name\n";
            }
        }

        // Alert if fields are empty and cancel form submit
        if (errmsg === "Oops, you're required to complete the following fields! \n") {
            form.submit();
        } else {
            alert(errmsg);
            return false;
        }
    }
</script>
    </head>
    <body>
        <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="return validate(form)">

            <p class="row">
                <input type="hidden" name="on0" value="Pickup and delivery" />Pickup and delivery<br />
                <select name="os0" onchange="checkPickup()">
                    <option value="" selected >Choose</option>
                    <option value="Pickup from Toowong, Brisbane">Pickup from Toowong, Brisbane $1.00 AUD</option>
                    <option value="Brisbane +$23.60">Brisbane +$23.60 =$1.00 AUD</option>
                </select>
            </p>
            <p class="row">Your daytime phone number<br />
                <input type="text" name="phone" value="Mobile's best!" onclick="clickclear(this, 'Mobile\'s best!')" onblur="clickrecall(this,'Mobile\'s best!')" />
            </p>
            <p class="row">Recipient's name<br />
                <input style="color: #ccc" class="name" type="text" name="name" value="His/her name" onclick="clickclear(this, 'His/her name')" onblur="clickrecall(this,'His/her name')" disabled />
            </p>
            <input name="custom" type="hidden"  />
            <input type="hidden" name="currency_code" value="AUD" />
            <input class="button" type="image" src="https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online." />
            <img alt="" border="0" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1"> -->
        </form>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:47:09+00:00Added an answer on May 28, 2026 at 6:47 pm

    This may be a simple misunderstanding of what you’ve written:

    if (form.os0.value != "Pickup from Toowong, Brisbane" ) {
        form.name.disabled = false; form.name.style.color = '#333';
    } else {
        form.name.disabled = true; form.name.style.color = '#CCC';
        //
    }
    

    translates to the following in plain english:

    If the value is NOT "Pickup from Toowong, Brisbane", enable the field, otherwise disable it.

    which is equivalent to:

    ONLY disable the field when the value is "Pickup from Toowong, Brisbane".

    I believe the logic you’re looking for is:

    if (form.os0.value == "Brisbane +$23.60" ) {
        form.name.disabled = false; form.name.style.color = '#333';
    } else {
        form.name.disabled = true; form.name.style.color = '#CCC';
        //
    }
    

    though it might be prettier to code this with a switch statement due to the involvement of specific cases.

    • See DEMO
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.