0

I can't get the value of the very last line of this code to be anything but static. I need it to be hardcoded so when they pull down the menu and select, it takes that value and puts it forth into the action script.

Any help?

<select id="yo5" onChange="asdf90()"><option>// Let the Page Refresh for each Pick Please!</option>
    <option id="yo4" value="<?php echo $test1 ?>"><?php echo $test1 ?></option>
    <option value="<?php echo $test2 ?>"><?php echo $test3 ?></option>
    <option><?php echo $test4 ?></option>
    <option><?php echo $test5 ?></option>
    <option><?php echo $test6 ?></option>
    <option><?php echo $test7 ?></option>
    <option><?php echo $test8 ?></option>
    <option><?php echo $test9 ?></option>
    <option><?php echo $test10 ?></option>
</select>

<script type = "text/javascript">
    function asdf90()
    {
        elem = <?php $test1 ?>;
        if(document.getElementById('yo5').value = elem)
        {
            alert('hi');
        }
    }
</script>       


<form method="post" action="<?php echo network_admin_url('site-new.php?action=add-site'); ?>">
<div id="nonexsist4"><input name="blog[domain]" type="hidden" value="" /></div>
1
  • <?php $test1 ?> does nothing. You need <?php echo $test1 ?>. Commented Jul 14, 2011 at 0:52

2 Answers 2

1

Put semi-colons after your echo statements..

<option><?php echo $test9; ?></option>

And use the == operator, not =

if(document.getElementById('yo5').value == elem)
Sign up to request clarification or add additional context in comments.

Comments

0

The code had several errors. I quote the correct code:

<select id="yo5" onChange="asdf90()">
    <option id="yo4" value="<?php echo $test1; ?>"><?php echo $test1; ?></option>
    <option value="<?php echo $test2; ?>"><?php echo $test3; ?></option>
    <option><?php echo $test4; ?></option>
    <option><?php echo $test5; ?></option>
    <option><?php echo $test6; ?></option>
    <option><?php echo $test7; ?></option>
    <option><?php echo $test8; ?></option>
    <option><?php echo $test9; ?></option>
    <option><?php echo $test10; ?></option>
</select>
<script type = "text/javascript">
function asdf90()
{
    var elem = "<?php echo $test1; ?>";
    if(document.getElementById('yo5').value == elem)
    {
        alert('hi');
    }
}
</script>

Regards

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.