www.webdeveloper.com
Results 1 to 6 of 6

Thread: disabled elements will not post (...)

  1. #1
    Join Date
    Jul 2011
    Posts
    6

    disabled elements will not post (...)

    I know it's expected behavior for disabled form elements not to post, because they cannot be successful. Fine. But even after I set disabled to false through a javascript function, the form elements will not get posted. Why is that?

    Does anyone know a workaround?

    Pseudo code here:
    Code:
    <input type=text name=blah disabled=disabled />
    
    function blah {
     all_blah = document.getElementsByName("blah");
     for (i=0; i<all_blah.length; i++)
     all_blah[i].disabled = false;
    }
    The intended form elements change their looks in browser, meaning they're enabled, I got javascript to acknowlegde they're enabled, but they still won't post.


    Thanks for any insights.

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    You need to show more code, to reveal how that function is called and all the associated markup.

  3. #3
    Join Date
    Nov 2010
    Posts
    1,099
    leaving out the parenthesis in your function declaration like this:
    Code:
    function blah {
    is bound to lead to problems, but as logic ali says, if you post pseudo code you're most likely only to get pseudo answers

  4. #4
    Join Date
    Nov 2007
    Posts
    431
    The following works fine. Compare with your real code to see why yours isn't working:

    Code:
    <form name="myForm">
    	<input type=text name=blah disabled=disabled />
    	<input type=text name=blah disabled=disabled />
    	<input type=text name=blah disabled=disabled />
    	<a href="javascript:void(0)" onclick="EnableAndSubmit()">GO!</a>
    </form>
    <script>
    function EnableAndSubmit() {
    	all_blah = document.getElementsByName("blah");
    	for (i=0; i<all_blah.length; i++)
    	all_blah[i].disabled = false;
    	document.myForm.submit();
    }
    </script>

  5. #5
    Join Date
    Jul 2011
    Posts
    6

    resolved

    Logic Ali, I was about to send you my code when I realized there's actually an issue on the server-side. I'll be posting this issue in a PHP forum. Thanks anyway.

    Everyone else, please disregard this thread as the data is actually being sent to the server-side.

    Xelawho, no disrespect intended, but that in fact doesn't even come close to a pseudo answer. Logic Ali said nothing close to what you're implying, he actually offered to help me as long as he could analyze some of the code.

    The reason I posted pseudo code, is because I wasn't worried about the javascript code per say, but just wanted to know if the behavior of the disabled element was supposed to remain the same even after it was re-enabled. Now I know it should work properly and that there was an error on the server-side.

    Whilst Logic Ali's answer would further make me investigate my code, yours wouldn't help at all. If you're really into helping people here, think of that next time you give out an answer.

    Cheers all. C ya.

  6. #6
    Join Date
    Nov 2010
    Posts
    1,099
    no, you're right - that wasn't a pseudo answer at all. no function will get very far without the parenthesis that you omitted, so I guess my answer falls into the category of non-psuedo/practical.

    I'm glad you found your solution. good luck with the rest of it.

Thread Information

Users Browsing this Thread

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

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