Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.location.href

Status
Not open for further replies.

NorthStarDA

IS-IT--Management
Mar 16, 2004
614
US
I need to edit someone elses Javascript Function:
Code:
function DoReload() 
{
	window.location.href = 'location_info.php?state=' + form1.state_id.options[form1.state_id.selectedIndex].value + '&county=' + form1.county_id.options[form1.county_id.selectedIndex].value + '&district=' + form1.district_id.options[form1.district_id.selectedIndex].value + '&school=' + form1.school_id.options[form1.school_id.selectedIndex].value + '&teacher=' + form1.teacher_id.options[form1.teacher_id.selectedIndex].value;
}

i need to add to the list of appended values a hidden form field, so far it gets values from all menu selects, but it sometimes gives me an error with my revision. this is what I tried to add.
Code:
+ '&vm_user_id=' + form1.vm_user_id.value;
but apparently this is not the proper way to get the value, can anyone see what I'm doing wrong?


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
what error does it give?

>>form1.vm_user_id.value
is this also a dropdown???

Known is handfull, Unknown is worldfull
 
The error is "Object doesn't support this property or method" on line 9, which is the line from my post.

And no, its a hidden form field.

thanks


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
did u try a plain old alert?
alert(form1.vm_user_id.value)

Known is handfull, Unknown is worldfull
 
i did try that, it outputs exactly what it should.

what's weird is that I've noticed that I get this error on the 3rd time I change the values of the conditional drop downs. always the 3rd change, no matter what field is changed, this error is thrown. When I close that page and re-open, i get 2 more successful changes to the lists, then the error is back on the 3rd. that part i can't figure out.


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 

Can you post the complete code to your page? It sounds like you have some script running when things are being changed that is causing the problem.

Dan
 
yes, i just found it- I have a conditional drop down list with about 5 fields on it, when 1 of the fields was changed- another select was built with no options to select, just a blank select field. I guess javascript doesn't like getting values from select lists when there are no options.

thanks everybody


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 

>> I guess javascript doesn't like getting values from select lists when there are no options.

If there is any possibility that no option is selected, or that no options exist, then you (the programmer) should always check to see if "selectedIndex != -1" before assuming that it is safe to get "options[selectedIndex].value".

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top