SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Any way to do this with js ?

    Hi ..

    i have html select menu , which include 2 value

    Code:
    <select name="cat">
    <option value=1>Lang1 - Lang2</option>
    </select>
    and i have 2 input with name L1 , and L2 .

    i need to view the Lang1 in L1 and Lang2 in L2 when user chnage or select .

    is there anyway to this with js ?

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    It is possible but I'm not sure how

    I'm sure some hardcore JavaScript coder will come along shortly and help you out

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think i can do it with php .. but i need help with Js

    how cna i get the value of the selected option ?

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    <script type='text/javascript'>
       
    document.getElementById('select').value;
    </script> 
    and change the SELECT to <select id='select'...

  5. #5
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like this?
    Code:
    <html>
      <head>
        <script language="javascript">
          function updateTextBoxes(frm)
          {
            var s = frm.sel1[frm.sel1.selectedIndex].text.replace(/\s/g, "");
            var i = s.indexOf("-");
            frm.txt1.value = s.substr(0, i);
            frm.txt2.value = s.substr(i + 1);
          }
        </script>
      </head>
      <body>
        <form>
          <select id="sel1" name="sel1" onchange="if(this.value != 0){updateTextBoxes(this.form);}">
            <option value=0>Select a city...</option>
            <option value=1>Buda - Pest</option>
          </select>
          <input type="text" id="txt1" name="txt1"/>
          <input type="text" id="txt2" name="txt2"/>
        </form>
      </body>
    </html>

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Ooops, I forgot it was a SELECT, like Jofa, ignore me

  7. #7
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice jofa , thx

    but there are problem with ur code !

    try it with 2 word , i mean

    i love - i hate


    u will get ilove and i hate , will eat the space !

  8. #8
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    ... replace(/\s-\s/g, "-")

  9. #9
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thx again !


Bookmarks

Posting Permissions

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