/    Sign up×
Community /Pin to ProfileBookmark

Newby Assistance pls

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:
[B]If there is an id field with value of xPhoto1 in the passing form, then do something….else do something else.[/B]

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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@nap0leonMar 15.2008 — Something like this:

<i>
</i>function FieldExists(field){
try{
if(document.getElementByID(field)){
// field exists
doSomething();
}
} catch(exception) {
//field does not exist
doSomethingElse();
}
}

function doSomethingElse(){
//something else goes here
}
function doSomething(){
//something goes here
}


When the page loads, you would run this at the bottom:
<i>
</i>&lt;script&gt;
FieldExists('xPhoto1');
&lt;/script&gt;
×

Success!

Help @pbaylis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...