424,294 Members | 1,898 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,294 IT Pros & Developers. It's quick & easy.

Form Results to display in order when submitting to an email

P: 24
Hi
I have created a form and need a bit of help with my javascript? My for is created using HTML and its using media surface. The form is set up to submit to an email. the problem is I have a drop down for GBP or percentage and then a box to type in the amount. When the results display in the email the are showing on a seperate line but I want this to appear together like GBP 5.00 or Percentage 9

Here is what ive got:

Form field

[HTML]<TR>

<TD class="tableBackLgtBlue2">EMPLOYER CONTRIBUTION</td>
<td class="tableBackLgtBlue2"><select size="1" name="sel13A_Type">
<option value="">Select</option>
<option value="GBP">GBP</option>
<option value="Percent">Percent</option>
</select>

<input type="text" name="txt13_Employer_Contribution">

</td>

</tr>

<TR>





<TD class="tableBackLgtBlue2">EMPLOYEE CONTRIBUTION</td>
<td class="tableBackLgtBlue2"><select size="1" name="sel14A_Type">
<option value="">Select</option>
<option value="GBP">GBP</option>
<option value="Percent">Percent</option>
</select>

<input type="text" name="txt14_Employee_Contribution">


</td>



</tr>
[/HTML]

This is the javascript Ive tried to create so the results will appear on the same line but its not working.


Expand|Select|Wrap|Line Numbers
  1. var x=document.getElementById("sel13A_Type");
  2.    alert(x.selectedIndex);
  3.  
  4.    //Add GBP to Employer Contribution
  5. if(x.selectedIndex==1){
  6. f.txt13_Employer_Contribution.value= "GBP" + f.txt13_Employer_Contribution.value;
  7.  
  8. }
  9. else if(x.selectedIndex==2){
  10. f.txt13_Employer_Contribution.value= "Percent" + f.txt13_Employer_Contribution.value;  
  11. }
  12. else
  13. {
  14. alert("You must select Percent or GBP");
  15. return false;
  16. }
  17.  
  18.    f.txt14_Employee_Contribution.value= oForm.sel14A_Type.value + f.txt14_Employee_Contribution.value;  
  19.  
  20.    processForm(f);
  21.    return true;    
  22. }
  23.  
  24.  
  25.  
  26. function processForm(oForm)
  27. {
  28.  
  29.  
  30.  
  31.     oForm.txt13_Employee_Contribution.value = oForm.sel13A_Type.value + oForm.txt13_Employee_Contribution.value;
  32.     oForm.txt14_Employee_Contribution.value = oForm.sel14A_Type.value + oForm.txt14_Employee_Contribution.value;
  33.  
  34.  
  35. }


Any ideas???
Sep 19 '07 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
Please use code tags when posting code, e.g.

[CODE=javascript]
Javascript code goes here
[/code]

When sending to email using the form action attribute, you are at the mercy of the browser and depending on the user's email software. The proper way would be to use a server-side script.
Sep 19 '07 #2

acoder
Expert Mod 15k+
P: 16,027
Added more information to the thread title.
Sep 19 '07 #3

P: 24
Anyone any ideas on this problem?
Sep 20 '07 #4

acoder
Expert Mod 15k+
P: 16,027
You could try removing the select elements once you've updated the text box.
Sep 20 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.