Get value of selection list by jQuery

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
bern_a3168
User
Posts: 53

Get value of selection list by jQuery

Post by bern_a3168 »

Need help on the client-side script.

the value for this field is character. if I select "1" it supposed to hide the "Nationality_of_spouse" field. the code below did not do the trick. not sure if I missed anything.

{ // keys = event types, values = handler functions
	"change": function(e) {
		// Your code
	if (this.value == '1') {
	    $(this).fields("Nationality_of_spouse").visible(false);
	    $(this).fields("Nationality_of_spouse").value("N/A");
     } else {
         		$(this).fields("Nationality_of_spouse").visible(true);
        } 
	}
}

appreciate if can help.


mobhar
User
Posts: 11709

Post by mobhar »

As always, you may press F12 from your browser, and check whether any Javascript error message from Console panel.


arbei
User
Posts: 9370

Post by arbei »

bern_a3168 wrote:

if I select "1"...

If your Edit Tag for the field is SELECT or RADIO (not textbox), you cannot use this.value to get the selected value, you should use $(this).val() or $(this).value().


bern_a3168
User
Posts: 53

Post by bern_a3168 »

Have changed the code as below and it's now working.

	if ($(this).fields("marital_status").value() != '1')
	{
	    $(this).fields("Nationality_of_spouse").visible(true);
     } else {
         		$(this).fields("Nationality_of_spouse").visible(false);
         		$(this).fields("Nationality_of_spouse").value("N/A");
        } 

Thanks!


Post Reply