开发者

php not picking up data from <select> help?

I'd really appreciate some help.

I have a php/html script开发者_JS百科 that displays a certain select with options based on $specqId, if the $specqId does not equal any of the specified numbers in the if/else if statement, then just display input

<?php if($specqId == 5){ ?>
<select id="a1" name"a1">
<option value="8.5 x 11">Letter 8.5" x 11"</option>
        <option value="8.5 x 14">Legal 8.5" x 14"</option>
        <option value="11 x 17">Tabloid 11" x 17"</option>

    </select>
<?php
}else if($specqId == 6){
?>  
    <select id="a1" name"a1">
        <option value="18 x 24">18" x 24"</option>
        <option value="20 x 30">20" x 30"</option>
        <option value="30 x 40">30" x 40"</option>

    </select>
<?php
}else if($specqId == 8){
    ?>
    <select id="a1" name"a1">
        <option value="8.5 x 11">8.5" x 11"</option>

    </select>
    <?php
}else {
?>
<input type="text" name="a1" id="a1" value="" size="30"/>
<?php }//end else ?>

Now, here is the weird thing, the php that processes this form, does not pick up anything except whats in the input tag, it does not pick up whats in the select tag...

any thoughts?


Just a little syntax error.
Change this

<select id="a1" name"a1">

to:

<select id="a1" name="a1">


You are giving all select fields the same name ('a1'). Since $_POST is an associative array, field names have to be unique. Also giving the fields the same ID is not valid HTML either.

Try this:

<?php if($specqId == 5){ ?>
<select id="size" name"size">
<option value="8.5 x 11">Letter 8.5" x 11"</option>
        <option value="8.5 x 14">Legal 8.5" x 14"</option>
        <option value="11 x 17">Tabloid 11" x 17"</option>

    </select>
<?php
}else if($specqId == 6){
?>  
    <select id="size" name"size">
        <option value="18 x 24">18" x 24"</option>
        <option value="20 x 30">20" x 30"</option>
        <option value="30 x 40">30" x 40"</option>

    </select>
<?php
}else if($specqId == 8){
    ?>
    <select id="size" name"size">
        <option value="8.5 x 11">8.5" x 11"</option>

    </select>
    <?php
}else {
?>
<input type="text" name="a1" id="a1" value="" size="30"/>
<?php }//end else ?>

And $_POST should look something like this:

array('size' => /* Selected value */, 'a1' => /* Input value */);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜