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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.