I have a screen with a horizontal pulldown menu bar defined across the top. When I click on the menu element I would like it to open a new web page and display a PDF document to the user. I've created a javascript function in 2 places, onoptionclick (menuoptions) and onclick (events). I used the get() to retrieve the value of Menu2 but it does not execute it. If I just put the window.open statement in it works fine, but I will have different PDF documents that I'd like to display.
Here is the my javascript
function myForm(){
var f = get("Menu2");
if (f === "F200"){
window.open("http://intra.smtl.com:8500/pdf/f200.pdf");
} else {
pui.click();
}
}
myForm();
Pulldown Menu questions
-
- Profound User
- Posts: 21
- Joined: Mon Dec 15, 2014 5:21 pm
- First Name: Randy
- Last Name: Heinz
- Company Name: Southwestern Motor Transport
- Phone: 210.662.3272
- Address 1: 4600 Goldfield
- City: San Antonio
- State / Province: Texas
- Zip / Postal Code: 78218
- Country: United States
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Pulldown Menu questions
The onoptionclick event should be passing the menu item (that was clicked) to your function. See the example, here:
http://www.profoundlogic.com/docs/pages ... Id=5275826
Instead of using get() to try to get the value, can you try just using the value that's passed to your onoptionclick event?
http://www.profoundlogic.com/docs/pages ... Id=5275826
Instead of using get() to try to get the value, can you try just using the value that's passed to your onoptionclick event?
-
- Profound User
- Posts: 21
- Joined: Mon Dec 15, 2014 5:21 pm
- First Name: Randy
- Last Name: Heinz
- Company Name: Southwestern Motor Transport
- Phone: 210.662.3272
- Address 1: 4600 Goldfield
- City: San Antonio
- State / Province: Texas
- Zip / Postal Code: 78218
- Country: United States
- Contact:
Re: Pulldown Menu questions
I very new to javascript, I've added the onoptionclick as suggested and it still did not work for me. When I hard coded the value "F200" in the javascript function, it worked, I'm do not understand how the value of this element is passed into the javascript function as noted below?
function processMenuOption(value) {
switch(value) {
case "F200":
// code to process menu option 01 would go here
window.open("http://intra.smtl.com:8500/pdf/f200.pdf");
break;
}
}
processMenuOption("F200"); (<---how do I place the choice value here)
function processMenuOption(value) {
switch(value) {
case "F200":
// code to process menu option 01 would go here
window.open("http://intra.smtl.com:8500/pdf/f200.pdf");
break;
}
}
processMenuOption("F200"); (<---how do I place the choice value here)
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Pulldown Menu questions
Not sure I know how you're coding this. is "processMenuOption" coded in a separate JS file and you call it from the "onoptionclick" property? Or are you coding this directly in the property? Or what?
Profound UI will have variables named 'value' and 'text' that are already set prior to running your routine. So, since the code you posted here is rather simple (but, of course, I don't know if there is more that you didn't post) it might be easy enough to just code it directly in the onoptionclick rather than defining a function.
So, if you did it that way, you could simply put this (without the 'function' definition) in your onoptionclick:
Or, if the PDF name always matches the "choice values" of the selected item, then you could simplify it to this:
Also, if "intra.smtl.com:8500" is the same server instance that you are running Profound UI on, I would leave that out of the URL. That way, if you ever change your server name or try to run this on a different server, you won't have to change your code. In that case, it'd look like this:
If your code is more complex and would benefit from putting it in a separate .js file, then you would want to keep the "function" parts the way you had them before and call it like this...
... this would make debugging a lot easier, so it makes a lot of sense for a more complex routine. The earlier suggestions are only given because your routine seems so simple that it may not be worth the extra effort of putting it in a separate file -- but it's up to you.
Does that help?
Profound UI will have variables named 'value' and 'text' that are already set prior to running your routine. So, since the code you posted here is rather simple (but, of course, I don't know if there is more that you didn't post) it might be easy enough to just code it directly in the onoptionclick rather than defining a function.
So, if you did it that way, you could simply put this (without the 'function' definition) in your onoptionclick:
Code: Select all
switch(value) {
case "F200":
// code to process menu option 01 would go here
window.open("http://intra.smtl.com:8500/pdf/f200.pdf");
break;
}
Code: Select all
// since "value" wil contain "F200", this will launch F200.pdf
window.open("http://intra.smtl.com:8500/pdf/"+ value + ".pdf");
Code: Select all
// since "value" wil contain "F200", this will launch F200.pdf
// this is a "relative" URL, it will launch documents from the server instance that my display is served from.
window.open("/pdf/"+ value + ".pdf");
Code: Select all
processMenuOption(value);
Does that help?
-
- Profound User
- Posts: 21
- Joined: Mon Dec 15, 2014 5:21 pm
- First Name: Randy
- Last Name: Heinz
- Company Name: Southwestern Motor Transport
- Phone: 210.662.3272
- Address 1: 4600 Goldfield
- City: San Antonio
- State / Province: Texas
- Zip / Postal Code: 78218
- Country: United States
- Contact:
Re: Pulldown Menu questions
Scott
Now that I know that the function definition is not needed, that awesome and I understand how it works.
Now that I know that the function definition is not needed, that awesome and I understand how it works.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Pulldown Menu questions
Great!
Yeah, I think that example in the documentation is a bit confusing. The intention was that this tells you what to set the widget's property to: And then the JS function would be a function called from a separate .js file, which it shows in the docs like this: So that is how that example works -- but it is confusing because it doesn't explain that very well. I'll go in there and see if I can make it clearer.
Yeah, I think that example in the documentation is a bit confusing. The intention was that this tells you what to set the widget's property to: And then the JS function would be a function called from a separate .js file, which it shows in the docs like this: So that is how that example works -- but it is confusing because it doesn't explain that very well. I'll go in there and see if I can make it clearer.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Pulldown Menu questions
Okay, I updated the docs a little bit. I put a screenshot of the widget property (instead of just text like was there before) and added some words to clarify things a litle bit. Hopefully that makes the docs easier to understand.
Who is online
Users browsing this forum: No registered users and 11 guests