I am attempting to alter the value within an input whenever a different option will get selected from the choose:

View image here.

The concept is the fact that for every ad package you'll have a different quantity of images (free will get images, $20 for 4 images etc.). With this particular number Then i wish to display the right quantity of upload fields for images.

I am already locating the values in the database for the amount of images for every package as you can tell within the code below:

<select name="ad_pack_id" class="dropdownlist required">

<?php foreach ( $results as $result ) { ?>

<option value="<?php esc_attr_e($result->pack_id); ?>" class="<?php esc_attr_e($result->pack_images); ?>"><?php esc_attr_e($result->pack_name); ?></option>

<?php } ?>

</select>

<input type="hidden" value="" name="packimages" id="packimages" />

I have attempted obtaining the value in the choose directly by doing:

mainform.ad_pack_id.options[selectedIndex].class.innerHTML

but this is not getting the amount of images.

How do i get the amount of images for that selected ad package without posting the shape first?

you might try jquery:

$("#ad_pack_id option:selected").val()

this will enable you to get the worthiness. to exhibitOrconceal upload fields you should use for instance the CSS display attribute:

$("#uploadfield_1").css("display", "none")
$("#uploadfield_1").css("display", "block")

do this:

document.mainform.ad_pack_id.options[Selected].className;

This code sets the input's value towards the selected option's value.

I simply added "id" attribute to choose menu

<select id="ad_pack_id" name="ad_pack_id" class="dropdownlist required">

<?php foreach ( $results as $result ) { ?>

<option value="<?php esc_attr_e($result->pack_id); ?>" class="<?php esc_attr_e($result->pack_images); ?>"><?php esc_attr_e($result->pack_name); ?></option>
<?php } ?>

</select>

<input type="hidden" value="" name="packimages" id="packimages" />


<script type="text/javascript">
var selectmenu = document.getElementById("ad_pack_id");
selectmenu.onchange = function()
{ //run some code when "onchange" event fires
var chosenoption = this.options[this.selectedIndex] //this refers to "selectmenu"
if (chosenoption.value!="nothing")
    {
    document.getElementById("packimages").value = chosenoption.value ;
    }
}
</script>