0

I have this code, it is quite simple but why isn't it working?

<html>
    <head>
        <script type=”text/javascript“>
            function Expedisi() 
            {
                var x=document.getElementById("cmb");//this the script for get data combo box
                var y = document.getElementById("txt");
                getCmb = x.value; 
                y.value = getCmb;
                alert(x);
            }
    </head>  
    <body>
        <select name="JENIS" id="cmb" data-role="slider" onChange="Expedisi()">
            <option value="Suplier">Sup</option>
            <option value="Expedisi">Exp</option>//if i pick one of this                          the value will be input on text box
        </select> 

        <input type="text" name="BKIRIM" id="txt" value=""> //this the destination value
    </body>
</html> 

Can anyone Helpme? because this script is not run?

Thanks

4
  • Have you check if you have javascript enabled on your browser? What browser are you using? Commented Jul 24, 2012 at 1:58
  • You didn't close the script tag Commented Jul 24, 2012 at 1:59
  • 1
    What's with the crazy quotes in type=”text/javascript“ Commented Jul 24, 2012 at 2:00
  • @Musa Thanks, it Work, the quote is the problems, its inaccurate Commented Jul 24, 2012 at 3:16

3 Answers 3

1

You don't need getCmb, and you don't need to declare an extra element.

Use this instead:

<html>
      <head>
          <script type="text/javascript">
             function Expedisi(t) 
             {
                var y=document.getElementById("txt");
                y.value = t.value;
              }
        </script>
      </head>  
   <body>

   <select name="JENIS" id="cmb" data-role="slider" onChange="Expedisi(this);">
                          <option value="Suplier">Sup</option>
                          <option value="Expedisi">Exp</option>
    </select> 

     <input type="text" name="BKIRIM" id="txt" value=""/>
    </body>
    </html> 
Sign up to request clarification or add additional context in comments.

4 Comments

If the form controls are put in a form, you can do t.form.BKIRIM.value = t.value;. And there is no need for the XML-style tags, the closing '/' is simply ignored.
@Patrick Im Using Adobe Dreamweaver CS3., any problem with that?
OK, I've create a fiddle with your code here, test it, and copy and paste the code from the html textarea into dreamweaver, and see if it works.
@Patrick Thanks , your script is work after I change the Quote
1

Your code is working for me. Try it here. http://jsfiddle.net/DLs7j/ That is the same exact code as yours. Copy, pasted.

Best

2 Comments

Maybe because I use the jquery mobile.., can you tell me the solution script for still run in jquery mobile?
Now that is a different question. You should have been clear on your question so others can help you out quickly. May I suggest you open a new question for that so the JQM experts here can contribute. JQM renders page differently, that said. Some js may not supported as.
1

You need to change the quotes around the script type tag. You are current using the ”” instead of ""; so change ”text/javascript” to "text/javascript".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.