pmilli0 Posted December 20, 2007 Share Posted December 20, 2007 Hi sorry if this is the wrong part of the forum, im new here. Change image by id -------------------------------------------------------------------------------- Im trying to write a javascript function that will change the image according to the product selected, therefore if a window is selected, the image will display, and if its a door a door will be displayed, any tips please. Below is the dropdown which i want to control what item and image is displayed <label for="productRangeID">Type:</label> <? $params = array( 'db'=>$GLOBALS['db'], 'table'=>'product_ranges', 'label_field'=>'productRangeName', 'value_field'=>'productRangeID', 'where'=>'WHERE productTypeID=2 OR productTypeID=3', 'order_by'=>'ORDER BY productRangeName', 'group_by'=>'', 'selected_value'=>$productRangeID, 'field_name'=>'productRangeID', 'class'=>'', 'multiple'=>0, 'width'=>'', 'on_change'=>'javascriptroductTypeFormAction()', 'on_blur'=>'', 'first_option'=>'Select Product Range', 'first_value'=>'', ); select_renderer::render($params); ?> [code=php:0] Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 20, 2007 Share Posted December 20, 2007 do something like this - name you product images something like this: product0001.jpg product0002.jpg product0003.jpg and etc. then use the code below - you will have to work it into you php script. <script language="javascript"> function showPic(selection) { document.getElementById("productpreview").src="product"+selection+".jpg"; } </script> <img id="productpreview" src="stockphoto.jpg"> <br><br> <select onchange="showPic(this.value)"> <option selected>Select Product Range <option value="0001">Apples <option value="0002">Oranges <option value="0003">Grapes </select> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.