Jump to content

php and javascript


krthk_sg

Recommended Posts

Hi all,

I have a form and i use a drop down box and fetch some data into it from db.I select a value from drop down box.And i call onchange event and call a javascript function and i do some validation here like setting some values.What i want to know is that from the javascript when i do a submit the page how do i get back the selected values.

 

here is the sample code,

$result = mysql_query($query, $mysql_access);

if(mysql_num_rows($result))

{

    ?>

    <TD align=left><select name=" h1" size="1" style="width:150px;margin:5px 0 5px 0;" onChange="javascript:Set('1');">

    <?php

    if($hh1 == '')    {

          ?>

          <option value="Heading" selected>Select field</option>

          <?php

    }

    else

    {

          ?>

          <option value="Heading">Select field</option>

          <?php

 

    }

 

 

    while($row = mysql_fetch_row($result))

    {

//      $r1=$row[0];

        if(($d1 == $row[0]))

        {

            ?>

            <option title ="y1" selected value="<?php echo $row[0]; ?>"><?php echo $row[0]; ?></option>

            <?php

        }

        else

        {

?>

            <option title ="r1" value="<?php echo $row[0]; ?>"><?php echo $row[0]; ?></option>

            <?php

        }

    }

    ?>

 

    </select>

<script>

document.test.submit();

</script>

 

 

Link to comment
https://forums.phpfreaks.com/topic/105888-php-and-javascript/
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.