Click to See Complete Forum and Search --> : restore? translate macromedia code
freaksarise
05-09-2003, 01:03 AM
I am looking at some Dreamweaver code to help learn. Could someone translate the line " if (restore) selObj.selectedIndex=0 "
The code is seen below:
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
I dont understand the condition. There appears to be none. And I also can't find the definition of RESTORE. Finally I do not understand the purpose of this line.
Thanks
FA
A1ien51
05-09-2003, 01:06 AM
restore would be a true(1) or false(0) sent to the function.
what that line does is set the selcet to the first item.
It is so when A person goes to reuse it and wants to go back to the same page they can. If this did not happen, then they you have to reset it to the default and goto the page due to the onchange....
Is that what you wanted?
A1ien51
freaksarise
05-09-2003, 01:39 AM
thanks. I changed the code 2 ways:
- i tried it with this line removed
- then i tried it with the value set to 1
there were no differences when clicking the back button or when refreshing/reloading.
I was thinking that you meant the following:
- user makes selection. page is redirected to new location.
- when user either clicks back, or clicks back and then refreshes the page ; the form field will remain as they input last instead of resetting to the default values.
No matter what I did the values stayed as the value the user selected.
Any thoughts?
Thanks
FA
A1ien51
05-09-2003, 01:51 AM
try using the word true instead of one.....Could also be the browser....Or I could be tired from working on my current project at 3 am........
A1ien51
freaksarise
05-09-2003, 12:24 PM
LOL. I know the feeling.
Here is the full script and form pulldown element.
I tried true and false but still no difference. I am in XP Home, using IE 6. Thanks Alien!!
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
THE FORM:
<form name="form1">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="x.htm" selected>nnnn</option>
<option value="x.htm">mmm</option>
</select>
</form>