+ Start a Discussion

web-to-case html syntax - how to use form.x.value



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>


So essentially in the webpage, someone can then type in values for:




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.");


return false;


if (form.description.value == "") {

alert("Description - required.");


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.");


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.");


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


Don't muck with the names or IDs of the components.  To get to the elements on the page, try using document.getElementById() instead (passing in the ID, obviously).

so does that mean instead of doing:


if (form.00N00000006tk2h.value == "":smileywink: {

alert("Request Category - required.":smileywink:;


return false;


I would do:


if (document.getElementById(00N00000006tk2h).value == "":smileywink: {

alert("Request Category - required.":smileywink:;


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.");


return false;



And this now works fine. Thank you so much for your help.