Textarea - multiple selections

I can’t seem to figure this out after doing some research on this topic. Any help would be appreciated.

I have a form with a textarea field that contains an include file. When I open the browser, it loads (as expected) and shows the html. All is good!

I would like to have the option of selecting different messages. I was thinking using a radio buton, make a selection and the include file would change to the selected file.

This is where I am having trouble getting another file loaded other than the original.

  <tr>
      <td width="27%" align="right" valign="top">Message:&nbsp;&nbsp;</td>
      <td width="73%"> <textarea rows="10" name="message" cols="63"><!-- #include file="message1.asp" --></textarea></td>
    </tr>

This is where I need some help. How can I change that to message2.asp, or message3.asp, etc. before I submit to post it?

Currently, I am manually changing it per the message file that I want to send. I know there must be a way to be more efficient!

Thank you!

I don’t really know a lot about .asp but I believe it is a server-side language. So assuming it works similar to PHP, I don’t suppose it would be possible to change the include interactively without a page refresh.
It may be possible to have a number of textareas, then show/hide them with the radios, but that would likely require javascript. If you go down the javascript route, it may as well be done entirely that way.
Again, javascript not my forte, but I think maybe include the includes as values in an array, with keys related to the radios, and have javascript show the related text according to the radio selection.

1 Like

Yes, asp is server side and it’s basically all content is html. And you are right that it work require a page refresh so the html writes to the textarea and it’s submitted to the post page in it’s entirety.

Thank you for your response.

I am somewhat confused which category it’s in now. SamA74 mentioned perhaps JS, and I thought it was moved. It shouldn’t be a NET or VB category. So which category is it currently in? Thanks for your attention.

Usually ASP is in .NET as that’s where all of the other ASP threads are. This one doesn’t seem to have anything to do with JS.

As I understand it, the OP wishes to pursue the JavaScript approach suggested by @SamA74:

2 Likes

Once the page is on the screen, I need the ability to choose which message I want to send. That message needs to display and then I can submit to post form that sends out an email. So I know that asp or .NET won’t handle that and I believe that @SamA74 has the right idea of using JS to load to the screen. If there is a better way, I am opened to whatever, because I can’t seem to find a solution with the many searches I done. I am sure that one of the many “smart” individuals on this forum will have the right approach.

Why are you using include files instead of having the available message options within your HTML file?

Simply, using includes makes things for efficient. If the html is used in other mailers or web pages, you only have to change it once rather than making the same changes to many of the same. Using an include would not affect the solution to this issues. Whether the html was on the same page or in an include - it’s the same. The include essentially puts the html on the page itself; it’s just in a different file.

If you are thinking using radio buttons, why not put a radio button beside each message option like this extremely basic example?

Am I correct in thinking each message is quite long so you would have only a short label beside each radio button and then display the full message after selection?

Thanks for the link but I know how to do that. What I need is for that value to write to the page because from there I will send it to a post page with that message in the email. If the option value doesn’t write or load to the page, it can’t carry forward to the post page.

You would create an action method that only renders the include as a partial html page. You would than use JavaScript to fetch that partial using http request and replace the text area content in the dom when different radio buttons are selected.

That sounds exactly what I need. That’s beyond my expertise and somewhat similar to what I have searching for. Do you know of any links where I can look at the code and go from there?

Thank you for thoughts.

I abandoned .NET for more climate friendly technology solutions. However, I have experience with .NET and could take a look if the code was made public on GitHub. Others would also be enabled to provide meaningful assistance.

To be clear, it’s ASP Classic not .NET.

It’s really not even much of an ASP page; basically it’s html. The only ASP is the include. So there is really not much to post.

It’s a form with a textarea, as below: Other than the include, it’s an html page with form fields that will post to a page that sends out emails.

 <tr>
      <td width="27%" align="right" valign="top">Message:&nbsp;&nbsp;</td>
      <td width="73%"> <textarea rows="10" name="message" cols="63"><!-- #include file="message1.asp" --></textarea></td>
    </tr>

I am just looking for a way to click a radio button to select one message of several to post to another page, but I need it to load to the page once I click on the radio button.

Another way to state this, let’s suppose I use the CodePen example posted by @Archibald. This is the code:


<form>
  <fieldset>
    <legend>Message</legend>
    <label><input type="radio" name="message" value="Merry Christmas">Merry Christmas</label>
    <label><input type="radio" name="message" value="Happy Birthday">Happy Birthday</label>
  </fieldset>
  <button>Send</button>
</form>

What I need is for the page to load that if I pick “Happy Birthday” that loads in the textarea field. If I want to edit that to say “Happy Birthday to YOU!”, I just make the edit on the page.

Then once done with form, I then click on submit to the post page that send out the email. So on the post page, I have a Request.Form (“message”) and the value of Happy Birthday passes through to that page.

Unfortunately JavaScript cannot do much to control ASP.

About the only way is to reload the page with a GET request (messing up the URL) or with a POST request which adds information to the headers.

That though does mean having a lot more ASP code to interpret either the GET request or the POST request, and do the appropriate thing. That is something that only someone familiar with ASP would be suitably placed to give solutions about.

I really don’t know how JavaScript can work with ASP in any other beneficial way, unless the issue of ASP is completely ignored and other JavaScript-based techniques are used to access information from the files instead.

So no solution here, but hopefully some jumping off points for others to help with.

As a last thought and perhaps your answer is the same. Rather than using a radio button, can you use jQuery with a drop down list that loads the file once you select the option?

Could you not just include all the message includes when you load the page and then just hide all except one with JS and then toggle messages on or off as required?

No need to fetch more messages unless we are talking hundreds of messages.

It could even be done with css using the checkbox hack which would be a valid use case for it in a form.

1 Like

Yes, I could load all to the page. There would be no more than 5.

I don’t know how to hide them and the height of the textarea could be small (see below) and each could have a title so I don’t have to view the entire html to determine the message.

Message1

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

Message2

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

…etc

The key is that only one can posts to the send page, and the name in the textarea (as above) for all would be the same, just one selected to post.