Jump to content
  • 0
Sign in to follow this  
skywalker

Javascript accesing the Authentication field

Question

I have the follwoing script and it wont recognize and allow me to set a variable that includes the authentication field for the table. I cannot find out how to refernece it. When I view source it is "display only" so doesnt have a form id aas the other fields do. My script is as follows....

The issue is etting the "bride" variable which needs to be the "Username"

I have this set as an update form but it doesnt matter to me if it is a different kind of datapage such as details report. I just need to know how to reference the "Username"

Incidentally I also tried replacing getElementById("authefield:Username").value; with getElementById("EditRecordUsername").value; .......but no joy!

Any help much appreciated

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

var Tradesman_param = gup( 'Tradesman' );

var bride = document.getElementById("authefield:Username").value;

var newURL = "http://tozak.org/mywedding/my-jobs/bride-dashboard/request-a-quote/?username=" + bride + "&Tradesman=" + Tradesman_param;


window.location=newURL;

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1

Hello, skywalker

I'm trying to answer your question.

First, try to remove "e" from your code: authefield:Username -> authfield:Username

Second: if this not helps, may be VIrtual field is a solution for you. You add a virtual field (just like HTML block) into your WebForm and set up that virtual field receives parameter from "Username" field. You create "display only" form element and it's value the same as you want (Username). Give it the label naming "Username" and your user sees the same Display Only field with expected value.

As far as I know, Virtual field value can be accessed via "getElementByName" function. This is not standard JavaScript function, but you can see, for example here: http://msdn.microsoft.com/en-us/library ... 85%29.aspx. The first (and the only) element returned by this method will be the one you need.

Hope one of these methods helps.

Share this post


Link to post
Share on other sites
  • 0

Thansk for your help. I managed to solve with the following solution....

1.Inserted a virtual field into the datapage form

2. set form element to hidden

3. select 'authenticated field' as the default value, and select the correct 'username' field from the fields list.

4. Changed the text in my code to the follwoing...

</div>
<script>
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

var Tradesman_param = gup( 'Tradesman' );

var bride = document.getElementById("cbParamVirtual1").value;

var newURL = "http://tozak.org/mywedding/wp-content/themes/life-collage/scripts/onPostJob.php?fname=brideQuoteRequest&username=" + bride + "&Tradesman=" + Tradesman_param;


window.location=newURL;

</script>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×