I want to put javascript code in my php page?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Selvermaster
    New Member
    • Sep 2010
    • 1

    #1

    I want to put javascript code in my php page?

    hello

    I have this page in my website

    I want to click on one of the Items in "Select" Option , and then click on "Sel" button to execute the Function "hotel"

    please help me becuase the Option Select is taken from database ..


    the problem is when I click on the button Sel , there is no action done


    This is the Code:


    Code:
    <html>
    <head>
    
    </head>
    <body>
    
    <script type="text/javascript">
    <!--
    function hotel() {
        var sel = document.getElementById("City");
        var domdom = sel.options[sel.selectedIndex].text;
        if (domdom=="دبي"){
            document.quiz.namehot.value="مونارك";
                    document.quiz.namehot1.value="2500";
        }
    else if(domdom=="دمشق"){
            document.quiz.namehot.value="القاعة الشامية";
                    document.quiz.namehot1.value="2500";
        }
    else if(domdom=="القاهرة"){
            document.quiz.namehot.value="جراند حياة";
                    document.quiz.namehot1.value="2500";
        }
    
    else if(domdom=="لندن"){
            document.quiz.namehot.value="سوسكس ادوارد";
                    document.quiz.namehot1.value="4500";
        }
    
    else if(domdom=="بيروت"){
            document.quiz.namehot.value="كراون بلازا";
                    document.quiz.namehot1.value="2500";
        }
    
    else if(domdom=="كوالالمبور"){
            document.quiz.namehot.value="شنغريلا";
                    document.quiz.namehot1.value="3500";
        }
    
    else if(domdom=="عمان"){
            document.quiz.namehot.value="شيراتون عمان";
                    document.quiz.namehot1.value="2500";
        }
    
    else if(domdom=="المغرب"){
            document.quiz.namehot.value="رويال منصور";
                    document.quiz.namehot1.value="2950";
        }
    
    else if(domdom=="شرم الشيخ"){
            document.quiz.namehot.value="شرم الشيخ";
                    document.quiz.namehot1.value="2500";
        }
    
    else if(domdom=="تركيا"){
            document.quiz.namehot.value="سويس";
                    document.quiz.namehot1.value="4500";
        }
    
    else if(domdom=="باريس"){
            document.quiz.namehot.value="ميريديان ايتوال";
                    document.quiz.namehot1.value="4500";
        }
    
    else if(domdom=="hi"){
            document.quiz.namehot.value="NH Hotel";
                    document.quiz.namehot1.value="4500";
        }
    
    
        
    else {
            document.quiz.namehot.value="Unknown";
            document.quiz.namehot1.value="Unknown";
    }}
    //-->
    </script>
    <form name="quiz">
    <select name="City" id="City" onchange="hi();">
    <option></option>
    <option>hi</option>
    <option>دبي</option>
    </select>
    <input type="text" name="namehot" value="">
    <input type="text" name="namehot1" value="">
    <input type="button" onclick="hotel()" value="Leave Tizag.com">
    </form>
    </body>
    </html>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    It should work, though you haven't defined the hi() function so you'll get an error when you change the option.

    Also, I assume you'll add the remaining cities via your PHP code.

    Comment

    Working...