Onclick seeking input value

Asked

Viewed 63 times

0

I have an html code that is inserted into a PHP variable

And inside I look for zip code, if I use

    <input alt='cep' class='text difCep' name='cep' id='cep' value='$cep'  type='text' onblur='xajax_procurarEndereco(this.value);$(\"#loading\").css(\"visibility\",\"visible\");' />

It works well, but the user wants a search button, so I adapted the code and there’s the problem, I can’t get the value of zip. I tested with Document.getElementById("field") and $('#cep'). val();

<label id='label_cep' for='cep'>CEP</label>
    <input alt='cep' class='text difCep' name='cep' id='cep' value='$cep'  type='text' />
    <button type='button' onclick='xajax_procurarEndereco(buscar input do cep);$("#loading").css("visibility","visible");' style="padding: 6px; height: 24px; margin-left: 10px;">Buscar</button>

1 answer

0


Both getElementById and the jQuery query work in this case, I can not think of another problem other than you have typed wrong, or else used simple quotes thus closing the quotes you opened in HTML. Take the example: https://jsfiddle.net/ar64m2gL/

  • It is best that you put the sample code directly in your answer, because if the link breaks in the future, your answer will no longer be as useful.

  • I play all this within a php variable, will it be that this may be causing not searching for the value?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.