I have this select list on a page <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> HTML: Scripts generates 5 select lists on the page. I need to change all select lists options to "Shipped" if customer clicks on "Shipped" on top of the page and "Processing" if customer clicks on "Processing" link (<a href="javascript:select_processing()">Processing</a>) Can somebody help me in doing so?
function selectOType(otype) { document.getElementById('otype[]').value = otype; } // <a href="javascript:selectOType('Processing');return 0;">Processing</a> // <a href="javascript:selectOType('Shipped');return 0;">Shipped</a> PHP: Maybe be some errors, just did that from mind.
I think i did not explain well... I have code like this <form> <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> some code...... <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> some code....... <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> HTML: I just want to change selected value for all select lists with one mouse click..... how to....?
One line is enough to do it <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script> function select_processing(){ jQuery(".txtText option[value=Shipped]").attr('selected', 'selected'); } </script> </head> <body> <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> some code...... <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> some code....... <select name="otype[]" class="txtText" id="otype[]"> <option value="Processing">Processing</option> <option value="Shipped">Shipped</option> </select> <a href="javascript:select_processing()">set to shipped</a> </body> </html> Code (markup):