bdmfatih Posted October 29, 2010 Share Posted October 29, 2010 HELLO my friend i want to put textbox this php codes but it does not work for this use combobox onchange event i call "bul()" function but it does not working <html> <head> <title>Talep Form</title> <?php function bul() { echo "<input type='text' name='sehir' id='sehir' size='51'>";//this part not working } ?> </head> <body> <form action="" method="post" name="talep_form"> <select name="ulkeler" id="ulkeler" onchange="bul()"> <?php $sql=mysql_query("select * from ulke"); while ($row=mysql_fetch_array($sql)) { $ulke_adi=$row['ulkeadi']; $id=$row['ulkeID']; echo "<option value=$id>$ulke_adi</option>"; //echo 'hello world'; ?> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217184-fatih/ Share on other sites More sharing options...
sharal Posted October 29, 2010 Share Posted October 29, 2010 Hi bdmfatih. onchange doesn't work with php as it is a client side html attribute, it does however work with javascript which might also solve your issue. <script type="text/javascript"> function bul () { var element = document.createElement("input"); element.type ="text"; element.name ="sehir"; element.id ="sehir"; element.size = "51"; document.getElementsByName("talep_form")[0].appendChild(element); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/217184-fatih/#findComment-1127923 Share on other sites More sharing options...
bdmfatih Posted October 29, 2010 Author Share Posted October 29, 2010 thanks but this code again and again add textbox but i want to add only one textbox can you help me Quote Link to comment https://forums.phpfreaks.com/topic/217184-fatih/#findComment-1127932 Share on other sites More sharing options...
sharal Posted October 29, 2010 Share Posted October 29, 2010 this should do the trick: <script type="text/javascript"> var added = 0; function bul () { if(added == 0) { var element = document.createElement("input"); element.type ="text"; element.name ="sehir"; element.id ="sehir"; element.size = "51"; document.getElementsByName("talep_form")[0].appendChild(element); added = 1; } } </script> Quote Link to comment https://forums.phpfreaks.com/topic/217184-fatih/#findComment-1127944 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.