www.webdeveloper.com
Results 1 to 3 of 3

Thread: How can i add another filed ?

  1. #1
    Join Date
    Nov 2002
    Posts
    4

    Question How can i add another filed ?

    Dear Friend,

    10x For this Line:

    Response.Write "<OPTION>" & rs("kod") & "</OPTION>"
    But how can i Add a text from another filed behind the combo box and it depend on the change in the combo box ?
    Ex.
    I choose On the combo "1" I get in the filed next on it "home"
    I choose On the combo "2" I get in the filed next on it "car"
    Etc…. ?

    Best Regards To All
    ================
    Adi Doron

  2. #2
    Join Date
    Nov 2002
    Location
    Peterborough, UK
    Posts
    166
    This question really belongs in the HTML/Javascript or dHTML forum I think, but I noticed you had another post regarding this which included ASP.

    To answer your question, I would suggest that you place an onChange() event in your <SELECT> tag.

    <SELECT NAME=myselect onChange="setfield(this);">
    <OPTION>1</OPTION>
    <OPTION>2</OPTION>
    </SELECT>

    function setfield(element) {
    if (element.value == '1') {
    document.formname.targetfield.value = 'home';}
    else {
    document.formname.targetfield.value = 'car';}
    }

    Where 'targetfield' is the NAME of the field you want to populate with the text. I'm assuming it was in a form.

    EDIT: Make sure to use 'element.value' in the script !
    Last edited by Rodders; 11-25-2002 at 05:03 AM.

  3. #3
    Join Date
    Nov 2002
    Location
    Peterborough, UK
    Posts
    166
    I'm rubbish at this stuff, so I post a reply then go away and try it only to find out it doesn't work ! Sorry.

    You need to give your <OPTION> tags a VALUE attribute.

    For my above example to work you need to do:

    <OPTION VALUE=1>1</OPTION>
    <OPTION VALUE=2>2</OPTION>

    But, I think there is a better way:

    <SELECT NAME=myselect onChange="document.formname.targetfield.value = this.value;">

    <OPTION VALUE=car>1</OPTION>
    <OPTION VALUE=home>2</OPTION>

    </SELECT>

    That saves having to keep a javascript function up to date with all the possible values, as long as you make sure your <OPTION>s are built correctly.

    I've tried this, and it works, I hope it is what you were after!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles