Form Chooser
I have a simple form that displays a 4 Radio Button Options. I would like to open up a different form based on the selection choosen. This is what i have, but when i test, the script does it does not register the first choice made, it is not until i change my choice when it executes. Do you have a good way to approach this? How do you suggest others accomplish the goal of having a form that shows selections of other forms to choose?
//On Change, execute...
fd.field('cosFormType').change(function(){
if (fd.field('cosFormType').value() == 1) {
fd.openForm('fd_Contact_Display.aspx');
}else if (fd.field('cosFormType').value() == 2) {
fd.openForm('fd_Contact_Display.aspx');
}else if (fd.field('cosFormType').value() == 3) {
fd.openForm('fd_Contact_Display.aspx');
}else if (fd.field('cosFormType').value() == 4) {
fd.openForm('fd_Contact_Display.aspx');
}
return true;
}) ;
//On Change, execute...
fd.field('cosFormType').change(function(){
if (fd.field('cosFormType').value() == 1) {
fd.openForm('fd_Contact_Display.aspx');
}else if (fd.field('cosFormType').value() == 2) {
fd.openForm('fd_Contact_Display.aspx');
}else if (fd.field('cosFormType').value() == 3) {
fd.openForm('fd_Contact_Display.aspx');
}else if (fd.field('cosFormType').value() == 4) {
fd.openForm('fd_Contact_Display.aspx');
}
return true;
}) ;
The enumaration of indicies start with 0 - not 1 - in this case. So, change your
fd.field('cosFormType').value() == 1
to
fd.field('cosFormType').value() == 0
and the following lines accordingly and it should work.
Regarding your second question - do you want our recommendation on how to do this? I think your way of doing it is fine. From a user experience point of view though, I'd have a button "Go" that'd transfer the user to the appropriate page (whilst still getting the value from the choice control), instead of having an onchange handler.
fd.field('cosFormType').value() == 1
to
fd.field('cosFormType').value() == 0
and the following lines accordingly and it should work.
Regarding your second question - do you want our recommendation on how to do this? I think your way of doing it is fine. From a user experience point of view though, I'd have a button "Go" that'd transfer the user to the appropriate page (whilst still getting the value from the choice control), instead of having an onchange handler.
To change the content type of an item simply add the Content Type field to your form (found among all the other fields of the list). Whenever the user selects another content type the page is automatically reloaded with the appropriate content-type specific form. You need to save that form in order for the change to take effect.
This worked for me. Look ok?
fd.field('cosFormType').change(function(){
if (fd.field('cosFormType').value() == 0) {
contentType.find('option').eq(2).prop('selected', true);
contentType.change();
}else if (fd.field('cosFormType').value() == 1) {
contentType.find('option').eq(3).prop('selected', true);
contentType.change();
}else if (fd.field('cosFormType').value() == 2) {
contentType.find('option').eq(1).prop('selected', true);
contentType.change();
}else if (fd.field('cosFormType').value() == 3) {
contentType.find('option').eq(4).prop('selected', true);
contentType.change();
}
return true;
}) ;
fd.field('cosFormType').change(function(){
if (fd.field('cosFormType').value() == 0) {
contentType.find('option').eq(2).prop('selected', true);
contentType.change();
}else if (fd.field('cosFormType').value() == 1) {
contentType.find('option').eq(3).prop('selected', true);
contentType.change();
}else if (fd.field('cosFormType').value() == 2) {
contentType.find('option').eq(1).prop('selected', true);
contentType.change();
}else if (fd.field('cosFormType').value() == 3) {
contentType.find('option').eq(4).prop('selected', true);
contentType.change();
}
return true;
}) ;
I've written the answer to you before I've seen the last message of yours. A nd yes, that's what I wanted to offer you. I'm going to go ahead and post the message anyway, for anyone's reference.
Regarding your first question: yes, you can. Add the content type field to your form and use the following code to change it:
// getting the SELECT element
var contentType = fd.field('ContentType').control()._el().find('select');
// setting the field to the second type (the 1 means 2nd element, indicies start with 0)
contentType.find('option').eq(1).prop('selected', true);
// reloading the form
contentType.change();
You can hide the content type field by adding the following line to its style editor in Forms Designer:
display:none;
Regarding your second question: you can add the content type to any form and do the above with it.
Regarding your first question: yes, you can. Add the content type field to your form and use the following code to change it:
// getting the SELECT element
var contentType = fd.field('ContentType').control()._el().find('select');
// setting the field to the second type (the 1 means 2nd element, indicies start with 0)
contentType.find('option').eq(1).prop('selected', true);
// reloading the form
contentType.change();
You can hide the content type field by adding the following line to its style editor in Forms Designer:
display:none;
Regarding your second question: you can add the content type to any form and do the above with it.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests