Jump to content

Ajax noob needs help


Incredinot

Recommended Posts

Hi..

Alright - so i have this form written in php and html - but i have one place where i would like some ajax.

The scenario is - if user is "a" he dont need to fill a text field, but if he is "b" then he needs to.

 

So is it possible to make something like:

 

<select name="something">
  <option value="1">1</option>
  <option value="2">2</option>
</select>

<!---
If the chosen option is "1" - then it should do nothing.
If its option 2, i should make something like:
<input type="text" name="something">
!-->

 

And im pretty blank regarding ajax. Just bought membership at lynda a while ago, so im looking further into it within short time..

But within that time, could someone help me out maybe?

Link to comment
https://forums.phpfreaks.com/topic/183574-ajax-noob-needs-help/
Share on other sites

 

 

Well using jQuery it would be something like

 

$('#id_of_select').change(function(){
  if($(this).val() == 2){
    $(this).insertAfter('<input type="text" name="somethingElse">');
  }
});

 

Thats just off the top of my head but i think its what you want.

Link to comment
https://forums.phpfreaks.com/topic/183574-ajax-noob-needs-help/#findComment-970652
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.