Jump to content

fatih


bdmfatih

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/217184-fatih/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/217184-fatih/#findComment-1127923
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/217184-fatih/#findComment-1127944
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.