Jump to content

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

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.