1
I need to make a form that, to enable a field is required to fill in a previous field.
Since there will be a pagination between a question and another (next or previous).
You can do it in Ajax?
I’m using PHP and I think this can be done with AJAX or Jquery, but I don’t know how to do it.
you can use the attribute
disabled
in fields with the functionattr
jQuery to enable fields whenever they exchange data...$("#nome").change(function() { if($(this).val().length > 0) { $("#nascimento").removeAttr("disabled"); } });
– Leonardo Bosquett
Thanks Leonardo although they do not like to be thanked in this were. rs <br> I have no knowledge in jquery and ajax but I will get. I didn’t express myself well, but I will use select and/or radio buttom. Would you have any tutorial? Thanks.
– fabricio_wm
Hello @fabricio_wm have some very easy examples here: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_disabled
– Leonardo Bosquett
About jQuery, this site helps a lot, has the complete reference and several examples: http://api.jquery.com/removeattr/
– Leonardo Bosquett
As for the select and radio button, I believe you will not have problems with them, the disabled attribute works with these too
– Leonardo Bosquett
Leonardo. It worked with input, but I want to enable a link with button appearance (use bootstrap). have any hints? Thanks.
– fabricio_wm
I feel like I’m almost there. I did so: <label class="radio"><input name="active" type="radio" class="form_1" value="S" onclick="if(Document.getElementById('title').disabled==true){Document.getElementById('title'). disabled=false}"/>Yes</label> <label class="radio"><input name="active" type="radio" class="form_1" value="N" onclick="if(Document.getElementById('title').disabled=true){Document.getElementById('title'). disabled=false}"/>No</label> <button>
– fabricio_wm
When I click, load the same page.
– fabricio_wm
Let us continue this Discussion in chat.
– fabricio_wm
you can do the following: <button class="" onclick="javascirpt:Document.Location = 'yourlink.php'" />
– Leonardo Bosquett
It’s the same thing. I click on the radio button and enable the button and when I click, load the same page changing from http://localhost/Dashboard/questionario_posvenda/teste.php? active=N to http://localhost/Dashboard/questionario_posvenda/teste.php? active=S
– fabricio_wm
I got it some other way. <button id="title" disabled="disabled" class="btn btn-Primary pull-right"><a href=".. /.. /Dashboard/questionario_posvenda/alert1.php">teste</a></button>
– fabricio_wm
I thought it worked, but it didn’t work. So, in addition to changing the font color, the link loads even if you click the disabled button.
– fabricio_wm
I got it. put the button with type="Ubmit and in the form I put the action by passing the link from the next page. Thanks.
– fabricio_wm
<form action="test.php" method="post"> <select> <option name="active" value="-" onclick="if(Document.getElementById('advance'). disabled==false){Document.getElementById('advance'). disabled=true}"/> --</option> <option name="active" value="FUNCIONARIO1" onclick="if(Document.getElementById('advance'). disabled=true{Document.getElementById('advance'). disabled=false}"/>EMPLOYEE 1</option> < <button id="forward" type="Submit" disabled="disabled" class="btn btn-Primary pull-right" >Forward</button> </form> @Leonardobosquett Can you help me? select bad
– fabricio_wm
could open a new question? we are running away from this context and code in comments will complicate our life :)
– Leonardo Bosquett
I’m already opening. Thank you.
– fabricio_wm