Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    displays message depend on the item that we've selected?

    We have a simple contact form. What we would like is: when the users select item from the dropdown list, we would like a diff. message displays/shows (depend on the item that they've selected). How can we do that?

    For example: if user selected Math – a message displays “Math: provide the problem." If user selected Physic – message displays “Physic:…”

    Thank you very much for your help. I really appreciate it a lot.

    <FORM NAME="contact_us" ACTION="Thankyou.asp" METHOD="POST" ID="Form1">
    <p>Fields marked with an asterisks (<font color="#FF0000">*</font>) are required.</p>
    <br>
    <p><strong>To:</strong><br>
    <select name="group_name" id="group_name" onchange="changeValue()">
    <option value="generalinf" selected>General Information</option>
    <option value="math">Math</option>
    <option value="physic">Physic</option>
    <option value="bio">Biology</option>
    <option value="other">Other</option>
    </select>
    </p>
    <p><strong><font color="#FF0000">*</font>From:</strong> (your email address)<br />
    <INPUT TYPE="text" NAME="from" TABINDEX="2" SIZE="50" MAXLENGTH="100" ID="Text1">
    </p>
    <p><strong><font color="#FF0000">*</font>Subject:</strong><br />
    <INPUT TYPE="text" NAME="subject" TABINDEX="3" SIZE="50" MAXLENGTH="100" ID="Text2">
    </p>
    <p>
    <p><strong><font color="#FF0000">*</font>Question or Comment:</strong><br />
    <!--<DIV ID="showMessage" name="showMessage">
    Math: please provide the problem
    </DIV>--->
    <textarea name="message" cols="50" rows="10" wrap="virtual" tabindex="4" ID="Textarea1"></textarea>
    </p>
    <br>
    <p>
    <input type="submit" value="Send Message" class="button" tabindex="5" ID="Submit1" NAME="Submit1" /></p>
    </FORM>

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following




    <script language="javascript">
    <!--
    mytxt=new Array()
    mytxt[0]=""
    mytxt[1]="Math: please provide the problem"
    mytxt[2]="Physics: ..............."
    mytxt[3]="Biology ---------"
    mytxt[4]="Other ???????"

    function changeValue(n){
    document.getElementById("showMessage").innerHTML=mytxt[n]
    }
    //-->
    </script>



    <FORM NAME="contact_us" ACTION="Thankyou.asp" METHOD="POST" ID="Form1">
    <p>Fields marked with an asterisks (<font color="#FF0000">*</font>) are required.</p>
    <br>
    <p><strong>To:</strong><br>
    <select name="group_name" id="group_name" onchange="changeValue(options.selectedIndex)">
    <option value="generalinf" selected>General Information</option>
    <option value="math">Math</option>
    <option value="physic">Physic</option>
    <option value="bio">Biology</option>
    <option value="other">Other</option>
    </select>
    </p>
    <p><strong><font color="#FF0000">*</font>From:</strong> (your email address)<br />
    <INPUT TYPE="text" NAME="from" TABINDEX="2" SIZE="50" MAXLENGTH="100" ID="Text1">
    </p>
    <p><strong><font color="#FF0000">*</font>Subject:</strong><br />
    <INPUT TYPE="text" NAME="subject" TABINDEX="3" SIZE="50" MAXLENGTH="100" ID="Text2">
    </p>
    <p>
    <p><strong><font color="#FF0000">*</font>Question or Comment:</strong><br />
    <DIV ID="showMessage">&nbsp;</DIV>
    <textarea name="message" cols="50" rows="10" wrap="virtual" tabindex="4" ID="Textarea1"></textarea>
    </p>
    <br>
    <p>
    <input type="submit" value="Send Message" class="button" tabindex="5" ID="Submit1" NAME="Submit1" /></p>
    </FORM>
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    hello,

    See how this works?

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function showMessage(str)
    {
    	var msg=new Array();
    	msg['physics']="physics msg";
    	msg['math']="math msg";
    	msg['misc']="misc. msg";
    	document.getElementById('info').innerHTML=msg[str];
    }
    </script>
    </head>
    <body>
    <form>
    	<select onchange="showMessage(this.options[this.selectedIndex].value)">
    		<option selected>Select. . .</option>
    		<option value="physics">Physics</option>
    		<option value="math">Math</option>
    		<option value="misc">Misc</option>
    	</select>
    </form>
    <div id="info"></div>
    </body>
    </html>
    Edit: Heh, guess I shouldn't have got up for a minute.


    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    THANK YOU VERY MUCH. YOU BOTH ARE VERY HELPFUL. YES, THEY BOTH WORK GREAT.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •