Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm working on a NewForm.aspx in SPD. The form controls and labels have an ID such as "ff6{$Pos}", "ff4description{$Pos}" and so forth. As I mouse over those items, I see SPD calls it a "code hyperlink" but googling that term lead me nowhere.

I'm working on some javascript code that will run on the form after it loads. I'm using jQuery and would like to reference the form elements using their HTML ID values. I'm writing the js code there on the page in SPD.

Is there a way of writing the javascript code so I can use those SPD-generated variables (e.g. "ff4description{$Pos}") so they get replaced with the actual values the same way the form elements themeselves get it? Some sort of "yeah, wrap it in percent symbols" thing?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Forget the SPD-generated IDs in the code. You'll need to get client-side markup since javascript runs on the client.

Use the F12 developer tools to find a client-side attribute you can hook into. As Eric says here, the Title attribute can be very helpful here. So, for example:

$("input[title=Title]").val("Here is the title");

Text fields and choice fields are pretty easy to set like this. More complex fields like lookups and People Pickers are doable will require a bit more effort.

share|improve this answer
    
I wish I could pick two answers; because both your and PiratEric's were great. You had less rep so I spread the love around. I found that grabbing it via jQuery was the way to go. I initially did up a bogus class, but will use the Title attrib instead. Fwiw, I did notice that there actually is a relation between "ff6{$Pos}" and the final HTML ID value; the ID looks like a GUID which then has "6" and what I bet is the web part position number; cooresponding to that {$Pos} var. –  Alan M Sep 26 '12 at 21:02
    
I upvoted Eric's so I guess we're even:) –  Derek Gusoff Sep 26 '12 at 21:03
add comment

Those will be dynamically filled in at runtime, so to access them you'll either have to view the resulting HTML source of the page to see the IDs, use a different selector like the Title attribute of the item, or replace the SPD generated IDs with your own.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.