#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    UK
    Posts
    2
    Rep Power
    0

    Unhappy very easy JavaScript... but not for me!


    I am trying very hard to do some javascript, but not very successfully. What I want to do is use a drop-down box on a form to provide the input to a text field in another form on the same page - but it's too hard!

    Can anyone help???

    Thanks very much.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    7
    Rep Power
    0
    The easiest way would be to use an onChange which executes a function once a selection is made in one list.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    UK
    Posts
    2
    Rep Power
    0
    thanks shmengy, but I had sort of worked that bit out, okay this is what I have so far - why doesn't it work?

    in the head:

    <script language="JavaScript">

    <!-- Begin
    function passText(str) {
    mainform.project.value = str;
    }
    // End -->
    </script>

    then in the body....


    <form name=selectform>
    Select an Option:<br>
    <select name="site" size=1>
    <option value="">Go to....
    <option value="test1">test1
    <option value="test2">test2
    <option value="test3">test3
    <option value="test4">test4
    <option value="test5">test5
    <option value="test6">test6
    </select>
    <input type=button value="Ok!" onClick="passText(this.form.site.options[this.form.site.selectedIndex].value);">
    </form>



    <CFFORM ACTION="edit.cfm" ENCTYPE="application/x-www-form-urlencoded" METHOD=POST name="mainform">
    <CFOUTPUT QUERY="GetEditInfo">
    <table border="0" width="601" cellspacing="0">
    <tr>
    <td width="121">Our Ref: </td>
    <td width="472"><input type="text" name="ourref" size="33" value="#ourref#"></td>
    </tr>
    <TR>
    <TD>Project:</TD>
    <TD>


    <input type="text" name="project" size="33" value="">


    where select form is the drop-down list to input into the field called "project" in mainform.

    HELP!!??!!
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    7
    Rep Power
    0
    I would put a onChange in the actual SELECT statement. Here is a page that I have done,

    My old web page

    and if you view the source it may help you. I hope!
  8. #5
  9. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    capendoc -

    cfml not my area, but, anyway, you need to change your reference to

    document.mainform.project.value = str;

    as all named forms are document properties.

    best,adios

IMN logo majestic logo threadwatch logo seochat tools logo