Jump to content


Photo

Including a textfile in a select drop-down menu?


  • Please log in to reply
1 reply to this topic

#1 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 09 September 2006 - 09:26 PM

I have a drop-down select menu.


Options are:
1
2

and 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:
<p>
<select name="messagetype">
<option value="1">1</option>
<option value="2">2</option>
</select>
</p>

<textarea name="message" rows="5" cols=30">

</textarea>

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?

#2 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 10 September 2006 - 04:08 PM

while begining assign the the includes of the mytext.txt files in a js var.

In your php code do something like

<?php 

echo '<script language="javascript"> var mytxt1 = new String("' . include("mytext.txt") . '") ;var mytxt2 = new String("' . include("mytext2.txt") . '") ; </script>

?>

then in your page do something like

<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>

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
Roy Simkes
Yet Another Parkyeri Developer




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users