Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Simple javascript question

Simple javascript question
Thread Tools
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 8, 2003, 02:23 AM
 
I have this code:

Code:
hhref=jaavascript:removeIP(document.ipForm.ipList.selectedIndex)
anyway to change java script:removeIP(document.ipForm.ipList.selectedInd ex) so that the form name can change and the call will still work? this.form.ipList.selectedIndex does not work. Thanks!

(i know there are typos, i put them there for macnn)
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Oct 8, 2003, 12:42 PM
 
I don't know Javascript but from reading your other post I think I know what's going on.

the string document.ipForm.ipList.selectedIndex includes the actual names of the form and control your working with. That is "ipForm" corresponds to the form name "ipForm" and "ipList" corresponds to the listbox name "ipList"

You can change the input parameter but make sure the form and control you put in the parameter exist. Your example says this.form.ipList.selectedIndex, which leads me to ask is there a form with the name "form" in your page and does that form contain a control with the name "ipList"?

EDIT: Assuming you're working with the function in the other post, you'd have to change all the 'hard coded' references to the control inside the function to re-use it. So even if the controls exist as I explained above, the function is coded to work with the control "document.ipForm.ipList". If you want it to be more generic, then make the names of the form and control parameters to the script and change all references to "document.ipForm.ipList" to whatver form and control you passed into the function. This would be beyond my passing knowledge of Javascript, but if you understand what I'm saying you should be able to modify that function with a little research.

Someone who knows Javascript PLEASE say loud and clear if I'm off base, these days I'm much more familiar with VBscript than anything else
(Last edited by Scarpa; Oct 8, 2003 at 12:51 PM. )
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:14 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2