You need to sign in to do that
Don't have an account?
web-to-case html syntax - how to use form.x.value
Hello
Using salesforce web-to-case, I was able to generate an html page where it contains something like this:
<label for="subject">Subject</label><input id="subject" maxlength="80" name="subject" size="20" type="text" /><br>
<label for="description">Description</label><textarea name="description"></textarea><br>
Request Category:<select id="00N00000006tk2h" name="00N00000006tk2h" title="Request Category"><option value="">--None--</option>
<option value="Blackberry">Blackberry</option>
<option value="CD Burning">CD Burning</option>
<option value="Directory Creation (Network Storage)">Directory Creation (Network Storage)</option>
<option value="Workstations">Workstations</option>
</select><br>
So essentially in the webpage, someone can then type in values for:
Subject
Description
Request Category (this is a custom field)
I also have some javascript code where I can use to enforce that certain fields must be populated/filled out and the code contains something like:
function form_validation(){
.
.
if (form.subject.value == "") {
alert("Subject - required.");
form.subject.focus();
return false;
if (form.description.value == "") {
alert("Description - required.");
form.description.focus();
return false;
So based on that, it looks like the form.x.value and form.x.focus are operating either on the name or id of the element in the form.
My problem is that I also need the custom field "Request Category" to be populated. And I am not sure if I am having problem because this is a picklist field, or if it's a custom field. But I tried to do something like this:
if (form.00N00000006tk2h.value == "") {
alert("Request Category - required.");
form.00N00000006tk2h.focus();
return false;
It doesn't do anything and in fact, it seems to deactivate the logic/check on the previous form.description.value .
I tried to change the web page logic so that instead of
Request
Category:<select id="00N00000006tk2h" name="00N00000006tk2h"
title="Request Category">
I use:
Request Category:<select id="00N00000006tk2h" name="RequestCategory" title="Request Category">
and then in the form_validation, use
if (form.RequestCategory.value == "") {
alert("Request Category - required.");
form.RequestCategory.focus();
return false;
And that works fine, except when the case does get generated, whatever value was selected from the webpage does not get saved into the case generated. SO it looks like i can't just change the name from 00N00000006tk2h to RequestCategory.
Any help would be greatly appreciated. thx
so does that mean instead of doing:
if (form.00N00000006tk2h.value == "" {
alert("Request Category - required.";
form.00N00000006tk2h.focus();
return false;
I would do:
if (document.getElementById(00N00000006tk2h).value == "" {
alert("Request Category - required.";
document.getElementById(00N00000006tk2h).focus();
return false;
ok. disregard last post, I got it working.
Essentially I did the following:
var RequestCategoryText = document.getElementById('00N00000006tk2h');
if (RequestCategoryText.value == "") {
alert ("Request Category - required.");
RequestCategoryText.focus();
return false;
And this now works fine. Thank you so much for your help.