PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Nov 23, 2017 2:17 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Aug 16, 2017 5:06 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
I have a Cart page that for some reason, is disabling the Postcode field. It's down to the theme.
So I am wondering if I use a getelementbyname, if I can disable the disabled function (if that is the cause).

To try and test it out, I am doing this, but to no avail.... trying to disable the field.

Syntax: [ Download ] [ Hide ]
  <script>document.getElementByName("wc_address_validation_postcode_lookup_postcode").disabled = true;</script>
 
  <form method='post'>
  <input type='text' name='wc_address_validation_postcode_lookup_postcode' class='input-text'>
  </form>


Any ideas?
ps we have to use Name instead of ID as the coded plugin uses Name. Not ID.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 5:25 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
There is no "getElementByName" function. There is a "getElementsByName", which returns a list, though.

If the problem is the theme disabling the postcode then the solution is to make the theme not disable the postcode. Adding more Javascript just makes things more complicated.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 5:35 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
Mmmm yes I quite agree, but where in their code, in the deep Wordpress theme, it is disabling that sort of thing, I don't know.
Trouble is, it's a third party plugin direct from Woocommerce. So something is causing it to not work. I wondered if it was an Ajax thing, but not sure.

Should this work in my test?
Syntax: [ Download ] [ Hide ]
  <script>
  document.getElementsByName("wc_address_validation_postcode_lookup_postcode")[0].disabled = false;

  </script>
 
  <form method='post'>
  <input type='text' name='wc_address_validation_postcode_lookup_postcode' class='input-text'>
  </form>

Happy to provide the plugin used, and the theme used. But would require you to have a copy of the theme to test it.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 6:45 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
It looks like it will work, yes. Make sure you're executing that after the page has loaded, or at least that you're putting the <script> after the <form>.

To find why it's disabled, first look at when it's disabled. Does the source of the page show the field as disabled? If so then PHP code is responsible. If not then you know it is happening Javascript.
Either way you can search the plugin and/or theme code for "postcode" and see what shows up.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 9:27 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
This is the HTML it's rendering:
Syntax: [ Download ] [ Hide ]
               
<p class="form-row form-row-first wc-address-validation-field wc-address-validation-billing-field">
        <input type="text" class="input-text" name="wc_address_validation_postcode_lookup_postcode" placeholder="Enter Postcode" value="" />
</p>


<p class="form-row form-row-last wc-address-validation-field wc-address-validation-billing-field">
    <input type="hidden" class="wc-address-validation-address-type" value="billing" />
        <a href="#" class="button">Find Address</a>
</p>

<div class="clear"></div>

<p class="form-row message notes wc-address-validation-results wc-address-validation-field wc-address-validation-billing-field">
        <select name="wc_address_validation_postcode_lookup_postcode_results" style="width: 100%" class="wc-address-validation-enhanced-select select billing"></select>
</p>

<hr/>

<p class="form-row form-row-first wc-address-validation-field wc-address-validation-shipping-field">
        <input type="text" class="input-text" name="wc_address_validation_postcode_lookup_postcode" placeholder="Enter Postcode" value="" />
</p>


<p class="form-row form-row-last wc-address-validation-field wc-address-validation-shipping-field">
    <input type="hidden" class="wc-address-validation-address-type" value="shipping" />
        <a href="#" class="button">Find Address</a>
</p>

<div class="clear"></div>

<p class="form-row message notes wc-address-validation-results wc-address-validation-field wc-address-validation-shipping-field">
        <select name="wc_address_validation_postcode_lookup_postcode_results" style="width: 100%" class="wc-address-validation-enhanced-select select shipping"></select>
</p>


And this does in fact appear at the bottom of the page:

Syntax: [ Download ] [ Hide ]
<script type='text/javascript'>
 
  document.getElementsByName("wc_address_validation_postcode_lookup_postcode")[0].disabled = false;</script>
 

But it isn't enabling the form field for Postcode.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 9:33 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
Are you sure the field is actually disabled? Does the DOM say it's disabled, like
Syntax: [ Download ] [ Hide ]
alert(document.getElementsByName("wc_address_validation_postcode_lookup_postcode")[0].disabled); // true?

or is there some other mechanism in effect?

Again, find out what the theme/plugin is doing.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 9:44 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
That generates a popup that says "false". What does that mean?

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 10:29 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
Means it's not actually disabled.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 10:34 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
Mmmmm damn it. So is there any way of finding out what is causing it to (I use this term cautiously) ... be disabled? Or readonly.
I suppose there is the chance that the Theme just has some sort of conflict with it.

Do you know of any other Wordpress Plugins that do Post/Zipcode lookups? Enter code, choose address from dropdown etc.
Surely there isn't just the one out there. Tho it is by WooCommerce. lol.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 3:48 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
simonmlewis wrote:
So is there any way of finding out what is causing it to (I use this term cautiously) ... be disabled? Or readonly.

I'll say it one more time before I give up:

Look at the theme or plugin, whichever you're talking about as being the source of the problem, to see how and why it is "disabling" the field. Then you can react accordingly.


Top
 Profile  
 
PostPosted: Wed Aug 16, 2017 4:22 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
I'll give up too. Absolutely no way of finding out. Without asking theme developers. Who are vague.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Thu Aug 17, 2017 1:20 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
Is the source code obfuscated?


Top
 Profile  
 
PostPosted: Thu Aug 17, 2017 2:41 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
No, the code is all there, but the cause to the problem could among any one of all the files in the folder structure.
Finding out which one it is, is likely to be impossible.

We should be getting some theme issues sorted next week, and the theme people may be able to help.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Thu Aug 17, 2017 9:54 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6587
Location: WA, USA
simonmlewis wrote:
Finding out which one it is, is likely to be impossible.

Not even remotely the case, but it's clear you don't even want to try so whatever.


Top
 Profile  
 
PostPosted: Thu Aug 17, 2017 10:00 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
How on earth do I "try", when it i Wordpress, and is full of JS and CSS and all sorts of included PHP files from all over.
I just would not know where to start.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group