Jump to content
  • 0

Javascript accesing the Authentication field


skywalker

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;
Link to comment
Share on other sites

4 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.

Link to comment
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>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...