select menu and display in the frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Fung

    select menu and display in the frame

    Dear Everybody,

    I have a double menu select javascript, could anyone know
    how to change it, so that the result will display in a frame
    name called "content", please?

    Here is the script.
    <html><body>
    <script>
    <!--
    v=false;
    //-->
    </script>
    <script>
    <!--
    if (typeof(Option) +"" != "undefined" ) v=true;
    //-->
    </script>
    <script>
    <!-- Begin
    if(v){a=new Array();aln=0;}
    function getFormNum (formName) {
    formNum =-1;
    for (i=0;i<document .forms.length;i ++){
    tempForm = document.forms[i];
    if (formName == tempForm) {
    formNum = i;
    correctForm = tempForm;
    break;
    }
    }
    return formNum;
    }
    function jmp(formName,el ementNum) {
    getFormNum(form Name);
    if (formNum>=0) {
    with (document.forms[formNum].elements[elementNum]) {
    i=selectedIndex ;
    if (i>=0) location=option s[i].value;
    }
    }
    }
    function O(txt,url) {
    a[k]=new Option(txt,url) ;k++;
    }
    function relate(formName ,elementNum,j) {
    if(v) {
    k=1;
    if(j==0) { // default category item
    a=new Array();
    O("Select day","");
    }

    if(j==1) { // 1st category items
    a=new Array();
    O("Select day","");
    O("Dec 25","2003/1225.html");
    }

    if(j==2) { // 2nd category items
    a=new Array();
    O("Select day","");
    O("March 6","2004/0306.html");
    }

    aln2=a.length;
    getFormNum(form Name);
    if (formNum>=0) {
    formNum = formNum + 1;
    with (document.forms[formNum].elements[elementNum]) {
    for (var i=options.lengt h-1;i>0;i--) options[i]=null;
    for (var i=1;i<aln2;i++) options[i-1]=a[i];
    options[0].selected=true;
    }
    }
    } else {
    jmp(formName,el ementNum);
    }
    }
    // End -->
    </script>
    <center>
    <table><tr>
    <td align=center valign=bottom>
    <form name=f1 method=post action="" onSubmit="retur n false;">
    <select name=m1 onChange="relat e(this.form,0,t his.selectedInd ex);
    document.f2.m2. focus();">
    <option value="/" class=select>Se lect Year
    <option value="/" class=year>2003
    <option value="/" class=year>2004
    </select></form></td>
    <td align=center valign=bottom>
    <form name=f2 method=post action="" onsubmit="retur n false;">
    <select name="m2" onchange="jmp(t his.form,0)">
    <option value="/" class=selectday >Select day
    <option value="/">
    </select></form></td>
    </tr></table>
    </body></html>
    --
    thank you very much for your help.
  • Dominique

    #2
    Re: select menu and display in the frame

    quick solution...
    i would suggest tho' that you think of a neater way to do this.
    Don't get me wrong, not saying its bad or wrong, just from what i see there
    are shorter and neater ways to do it :0)

    Good luck

    Change this funcion to create the url and make it the form's ACTION
    then submit the form


    function jmp(formName,el ementNum) {
    getFormNum(form Name);
    if (formNum>=0) {
    with (document.forms[formNum].elements[elementNum]) {
    i=selectedIndex ;
    if (i>=0) frmAction=optio ns[i].value;
    document.forms[formNum].action = frmAction;
    document.forms[formNum].submit();
    }
    }
    }

    give the form the target you want, so when it is submitted above, it'll
    sumit to that frame

    <form name=f2 method=post TARGET="FRAME_N AME" action="" onsubmit="retur n
    false;">
    <select name="m2" onchange="jmp(t his.form,0)">
    <option value="/" class=selectday >Select day
    <option value="/">
    </select></form>


    cheers


    "John Fung" <jskfung@netvig ator.com> wrote in message
    news:dccec36.04 05062221.12c849 46@posting.goog le.com...[color=blue]
    > Dear Everybody,
    >
    > I have a double menu select javascript, could anyone know
    > how to change it, so that the result will display in a frame
    > name called "content", please?
    >
    > Here is the script.
    > <html><body>
    > <script>
    > <!--
    > v=false;
    > //-->
    > </script>
    > <script>
    > <!--
    > if (typeof(Option) +"" != "undefined" ) v=true;
    > //-->
    > </script>
    > <script>
    > <!-- Begin
    > if(v){a=new Array();aln=0;}
    > function getFormNum (formName) {
    > formNum =-1;
    > for (i=0;i<document .forms.length;i ++){
    > tempForm = document.forms[i];
    > if (formName == tempForm) {
    > formNum = i;
    > correctForm = tempForm;
    > break;
    > }
    > }
    > return formNum;
    > }
    > function jmp(formName,el ementNum) {
    > getFormNum(form Name);
    > if (formNum>=0) {
    > with (document.forms[formNum].elements[elementNum]) {
    > i=selectedIndex ;
    > if (i>=0) location=option s[i].value;
    > }
    > }
    > }
    > function O(txt,url) {
    > a[k]=new Option(txt,url) ;k++;
    > }
    > function relate(formName ,elementNum,j) {
    > if(v) {
    > k=1;
    > if(j==0) { // default category item
    > a=new Array();
    > O("Select day","");
    > }
    >
    > if(j==1) { // 1st category items
    > a=new Array();
    > O("Select day","");
    > O("Dec 25","2003/1225.html");
    > }
    >
    > if(j==2) { // 2nd category items
    > a=new Array();
    > O("Select day","");
    > O("March 6","2004/0306.html");
    > }
    >
    > aln2=a.length;
    > getFormNum(form Name);
    > if (formNum>=0) {
    > formNum = formNum + 1;
    > with (document.forms[formNum].elements[elementNum]) {
    > for (var i=options.lengt h-1;i>0;i--) options[i]=null;
    > for (var i=1;i<aln2;i++) options[i-1]=a[i];
    > options[0].selected=true;
    > }
    > }
    > } else {
    > jmp(formName,el ementNum);
    > }
    > }
    > // End -->
    > </script>
    > <center>
    > <table><tr>
    > <td align=center valign=bottom>
    > <form name=f1 method=post action="" onSubmit="retur n false;">
    > <select name=m1 onChange="relat e(this.form,0,t his.selectedInd ex);
    > document.f2.m2. focus();">
    > <option value="/" class=select>Se lect Year
    > <option value="/" class=year>2003
    > <option value="/" class=year>2004
    > </select></form></td>
    > <td align=center valign=bottom>
    > <form name=f2 method=post action="" onsubmit="retur n false;">
    > <select name="m2" onchange="jmp(t his.form,0)">
    > <option value="/" class=selectday >Select day
    > <option value="/">
    > </select></form></td>
    > </tr></table>
    > </body></html>
    > --
    > thank you very much for your help.[/color]


    Comment

    Working...