kvnmck18 Posted June 28, 2006 Share Posted June 28, 2006 I'm tryign to get a javascript that when you select an option from the menu it writes the value in text not in a form. I've been trying too long and still no progress. It'd be nice if you could make the value write in a div. This is what I have so far I just left the input box so you could see where I am coming from (though I want it gone and the "value text" to be presented in a <div> "value" </div>___________________________________________________<html><head><script type="text/javascript">function openKindofSel(){var kind_open=document.getElementById("kind")document.getElementById("show").value=kind_open.options.value}</script></head><body><form><select id="kind" onchange="openKindofSel()"> <option>select</option><option value="//pic[@category=kitchen]">Kitchen</option> <option value="//pic[@category=bath]">Bath</option> <option value="//pic[@category=home]">Home</option></select><input type="text" id="show"></form></body></html>___________________________________________________Thank you Link to comment Share on other sites More sharing options...
pulpfiction Posted June 28, 2006 Share Posted June 28, 2006 Try this code..... <html><head><script type="text/javascript">function openKindofSel(){var kind_open=document.getElementById("kind")document.getElementById("show").value=kind_open.options.valuewriteindiv(kind_open.options.value,'test')}function writeindiv(text,id){ if (document.getElementById) { x = document.getElementById(id); x.innerHTML = ''; x.innerHTML = text; } else if (document.all) { x = document.all[id]; x.innerHTML = text; } else if (document.layers) { x = document.layers[id]; text2 = '<P CLASS="testclass">' + text + '</P>'; x.document.open(); x.document.write(text2); x.document.close(); }}</script></head><body><form><select id="kind" onchange="openKindofSel()"><option>select</option><option value="//pic[@category='kitchen']">Kitchen</option><option value="//pic[@category='bath']">Bath</option><option value="//pic[@category='home']">Home</option></select><input type="text" id="show"><div style="border:1px solid black;" id="test">Text will appear here</div></form></body></html> Link to comment Share on other sites More sharing options...
kvnmck18 Posted June 28, 2006 Author Share Posted June 28, 2006 I've been trying this...it's close... I just need it to reload when a new one is selected.________________________________________________________<html><head><script type="text/javascript">function openKindofSel(){var kind_open=document.getElementById("kind")document.getElementById("show").value=kind_open.options.value}</script></head><body><form><select id="kind" onchange="openKindofSel()"><option value="//pic[@category]">Show All</option><option value="//pic[@category=kitchen]">Kitchen</option><option value="//pic[@category=bath]">Bath</option><option value="//pic[@category=home]">Home</option></select><input type="text" id="show"><script type="text/javascript">document.write(document.getElementById("kind").value)</script></form></body></html> Link to comment Share on other sites More sharing options...
kvnmck18 Posted June 28, 2006 Author Share Posted June 28, 2006 Oh, your's works great. Thanks so much. but what's wrong with mine...can you fix it? Link to comment Share on other sites More sharing options...
pulpfiction Posted June 28, 2006 Share Posted June 28, 2006 Its pretty much yours, just added a function to write the text in div......... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now