Newby help please - referencing ID parameter

Discussion in 'JavaScript' started by pbaylis, Mar 12, 2008.

  1. #1
    I'm a cold fusion developer who knows nothing about javascript. So, I need some help here please.

    I have set hidden form fields in my form template, as follows:

    <form name="theform" action="actionpage"..etc>
    <input type="hidden" id="xPhoto1" name="Photo1" value="#Photo1#">
    <input type="hidden" id="xPhoto2" name="Photo2" value="#Photo2#">
    <input type="hidden" id="xPhoto3" name="Photo3" value="#Photo3#">
    <input type="hidden" id="xPhoto4" name="Photo4" value="#Photo4#">
    <input type="submit"...etc>
    </form>

    The page that processes this form needs to check for the existence of the ID attribute in the above form. In words, it would work something like this:
    If there is an id field with value of xPhoto1 in the passing form, then do something....else do something else.

    I need to keep the name attribute as it is because it references a database field. I was hoping I could use the ID attribute to reference this particular hidden field without also referencing a form field name.

    Thanks in advance for any assistance.

    Kind regards,
    Paul
     
    pbaylis, Mar 12, 2008 IP
  2. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    if (document.getElementById('xPhoto1') != null)
    {
       // do work here
    }
    
    Code (markup):
     
    roy.laurie, Mar 12, 2008 IP