Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
getOptions()[].value is null error
System
The following code is giving me a javascript error of getOptions()[].value is null or not an object
That would be on this line:
var myvalue = item.getOptions()[typeItem.getValue()].value;
Does another set of eyes see something I don't - I tried to in the main function var typeItem = 0; but that didn't work then I tried to create a dummy var called flag and had something like this
var flag = item.getOptions()[typeItem.getValue()].value = 0;
but no luck as well - likely/hopefully it's something small I don't see
function autourl()
{
IWEventRegistry.addItemHandler("/pm", "onItemChange", selectedValue);
selectedValue(IWDatacapture.getItem("/pm"));
}
function selectedValue(item)
{
var typeItem = IWDatacapture.getItem("/pm");
var typeIndex = typeItem.getValue();
var typefield = IWDatacapture.getItem("/ByLine_Name");
var myvalue = item.getOptions()[typeItem.getValue()].value;
var mytext = item.getOptions()[typeItem.getValue()].text;
var mylink = "<a href ='/sc?templ=managerBio&id="+myvalue+"'>"+mytext+"</a>";
//window.alert(myvalue);
//window.alert(mylink);
typefield.setValue(mylink);
IWDatacapture.redraw();
}
autourl();
Thanks
Find more posts tagged with
Comments
JonathonG
It would seem on initial look that typeItem.getValue() is returning a blank string, and not a numeric value. I noticed that you put the return of this into a variable (typeIndex) a little bit earlier in your function. What happens if you do alert(typeIndex)?
If that gives you a value, I would try replacing the typeItem.getValue() on your problem line with typeIndex. It's much simpler.
The only other thing I can think of is that "/pm" is either not a select list or it has no options specified.
Jonathon
Independent Interwoven Contractor
Migrateduser
1) If I do an alert of the typeIndex I don't get anything returned - it doesn't even fire the alert - just the initiall error message
2) If I change the problem line to typeIndex I get an error null is null or not an object
Migrateduser
Actually - I moved the alert up after this line:
var typefield = IWDatacapture.getItem("/ByLine_Name");
and it does indeed return null
JonathonG
Could you post the datacapture.cfg section that defines the "pm" element?
Jonathon
Independent Interwoven Contractor
Migrateduser
Actually - I just read this in the form api about empty strings
https://support.interwoven.com/library/manuals/templating/html/formapi1.0/formapi_15.html#SEC15
so I added a typeItem.setValue(0):
var typeItem = IWDatacapture.getItem("/pm");
typeItem.setValue(0)
var typeIndex = typeItem.getValue();
Code works now without the error - however it selects the first person from the picklist - which I don't want to occur!
Any thoughts
Migrateduser
Info you requested:
<item name="pm">
<label>Portfolio Manager</label>
<description>Select applicable Portfolio Manager from list and then proper code is generated in the text box below so a link to that managers bio appears.</description>
<database deploy-column="f" />
<inline command="d:/iw-home/Interwoven/TeamSite/iw-perl/bin/iwperl.exe d:/iw-home/Interwoven/TeamSite/httpd/iw-bin/inline_get_pm.ipl"/>
</item>
JonathonG
Seems that what you want to do is to check for the null condition. If null, you probably want to set the value of your text field to blank. So, you'd have something like:
var typeItem = IWDatacapture.getItem("/pm");
var typeIndex = typeItem.getValue();
var typefield = IWDatacapture.getItem("/ByLine_Name");
if (typeIndex != null)
{
var myvalue = item.getOptions()[typeIndex].value;
var mytext = item.getOptions()[typeIndex].text;
var mylink = "<a href ='/sc?templ=managerBio&id="+myvalue+"'>"+mytext+"</a>";
typefield.setValue(mylink);
}
else
{
// set the value in your text field to blank
typefield.setValue("");
}
IWDatacapture.redraw();
Hope this helps,
Jonathon
Independent Interwoven Contractor
Edited by JonathonG on 01/09/04 11:51 AM (server time).
Migrateduser
Great - thanks - that appears to have done the trick!
I had tried an if/else earlier in the day but with different logic
so thanks
Migrateduser
Actually I found a small bug - what should I do if a user edits the byline field manually - what's happening is the field get's set to null when they go back in and try to edit their data!
Any thoughts would be great!
So basically - I'm just looking at testing to see if data is already eneterd in that field - if yes then leave it their - if not set the field to null!
Migrateduser
Actually possibly just commenting out this line may be the full solution:
typefield.setValue("");
JonathonG
Correct. And actually, if you do that, you don't need the "else" anymore.
My code assumed that the only way a value got put in that box is by them selecting from the drop-down. If that's not true (sounds like it isn't), then you want to take out that line.
Jonathon
Independent Interwoven Contractor