extrovertive Posted September 9, 2006 Share Posted September 9, 2006 I have a drop-down select menu.Options are:12and then a textarea box.If a user pull-down and select 2 from the drop-down select menu, then the textarea value will include a textfile.Example:[code]<p><select name="messagetype"><option value="1">1</option><option value="2">2</option></select></p><textarea name="message" rows="5" cols=30"></textarea>[/code]Now if, I select 2 from the drop-down menu, the textarea will be like this:<textarea name="message" rows="5" cols=30"><?php include("mytext.txt");?></textarea>I not a Javascript person, so can anyone help me with this? Quote Link to comment Share on other sites More sharing options...
radalin Posted September 10, 2006 Share Posted September 10, 2006 while begining assign the the includes of the mytext.txt files in a js var.In your php code do something like[code=php:0]<?php echo '<script language="javascript"> var mytxt1 = new String("' . include("mytext.txt") . '") ;var mytxt2 = new String("' . include("mytext2.txt") . '") ; </script>?>[/code]then in your page do something like[code]<p><select name="messagetype" onChange=" message.value = ( this.value == 1 ? mytxt1 : mytxt2 ); "><option value="1">1</option><option value="2">2</option></select></p><textarea name="message" id="message" rows="5" cols=30"></textarea>[/code]This should work but I'm certain that you have to change that include("mytext.txt") thing in the echoing. I'm not sure if it will work. But above that it should be ok 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.