Concatenate Text To Refer To A Variable ?

Nov 10, 2010

I am trying to concatenate text to refer to a variable:

It give me undefined instead of 17. How should this be done without using eval() ?

View 21 Replies


ADVERTISEMENT

Concatenate Dynamic Variable Names

Jul 23, 2005

I have a table that I populate with an array using ASP. As each row is created, the form object names are appended a numeric, such as:

i = 1
<select name="select<%=i%>">
...
...
...
i = i+1
next

I then pass "i" to a javascript function, so that I can access the values of each form object. I can't figure out how to properly concatenate the "i" and still allow access to the value in the form object. Currently I have:

var ps = 'platSymbol' + I;
alert(ps)
var sel = 'document.frmUpdPlatGrp.' + ps + '.value'
alert(sel)

I know I'm wrong, as this comes back as a complete string. Ultimately I want to have something like this:

var s = document.frmUpdPlatGrp.platSymbol2.value - so that I can actually get the value.

View 2 Replies View Related

Ability To Refer To Function By Variable

Mar 26, 2010

I have a function that sets a value of this.name. If I call a function of that function (is there a better term for that?), I can get the value of that name with this.name. However, if I save that function's function as a variable, and THEN call it, this.name is undefined.

I don't think my vocabulary is clear enough, so here's my example:
function Ninja(name){
this._name = name;
this.getName = function(){
return "ninja "+this._name
}}

sam = new Ninja("sam");
assert( sam.getName() == "ninja sam", "Ninja's name is ninja sam" );
sam2 = new Ninja("sam2");
sam2getName = sam2.getName;
assert( sam2getName() == "ninja sam2", "Ninja 2's name is ninja sam2" ); //fails
log("Ninja 2's name is actually "+sam2getName()) // actually "ninja undefined"

(Note: Use of "ninja" and assertions are because I was playing with the code in John Resig's java runner thingie: [URL]). The reason I want to be able to refer to a function by a variable is because I want to pass the function to something else that requires a function to be passed in, such as an ajax callback or something. Anyway... why is this.name undefined in the second example?

View 7 Replies View Related

Refer To Text Of Url

Jul 20, 2005

How can I access the text of an url via javascript, ie. get 'foo' (and
send it as parameter in goto(), in example:

<a href="javascript:goto([foo])">foo</a>

Or refer to it globally?

document.links.href.text.value ?
this.href.text ?

View 6 Replies View Related

JQuery :: How To Concatenate Text

Nov 18, 2009

I've tried various methods but haven't had any luck as of yet. I'm returning a series of 4 objects via AJAX calls. When each object loads, I'd like to iterate through it (no problem), and populate the "value" attribute of a hidden input field with each value from the object. I can't seem to find a way to intermingle jQuery and '+=', or find a jQuery substitute.

[Code]....

View 2 Replies View Related

Converting Int To String - Variable To Concatenate It As A String To Find An Input Box

Jun 26, 2010

I have a for loop: Code: for( var i = 0; i < aInput.length; i++ ) I want to use this i variable to concatonate it as a string to find an input box

Code:
var j = i;
var qualname = "discountqualifier" + j;
qualname.toString();
if ( inputName == ( qualname ) )
{

Assuming I have a input box named discountqualifier0, discountqualifier1, discountqualifier2 etc...

View 4 Replies View Related

Concatenate Two Variables

Aug 13, 2006

i am building a site and i need to know how i can put a variable in to a string and afther i did it it must be 1 new variable.example:

VAR1 = 'hello'
VAR2 = 1
i want to get
VAR3 = 'hello1'

View 1 Replies View Related

Refer To A Selection Box

Mar 17, 2009

I have to add a selection box in my assignment, but I don't know how to refer to it in the javascript.

Here is the javascript code I am trying to refer to the selection box with that doesn't work [code]...

View 7 Replies View Related

How To Concatenate Form Fields?

Aug 9, 2006

I have the following inputs in an HTML form:

<td>(<input class="phonetext" maxlength="3" name="phoneareacode" size="3" type="text" value="">)
<input class="phonetext" maxlength="3" name="phoneexchange" size="3" type="text" value="">-
<input class="phonetext" maxlength="4" name="phonenumber" size="4" type="text" value=""></td>

I would like to combine all three of these values into one hidden field like this:

<input type="hidden" id="phone" name="phone" value="?">

With the? being the three values merged together...

View 1 Replies View Related

How To Concatenate Vars For This Code

Apr 26, 2010

I have the following code:Code:

Code:
Event.observe($('store_locator_form'), 'submit', function() {
$('storelocator-results').style.visibility = 'visible';

[code]....

View 4 Replies View Related

Concatenate A Loop Counter Into An Id #

Aug 20, 2011

I'm trying to condense the following code into a for loop, but cannot figure out how concatenate the loop counter into the id number

jQuery('#product-1').hover(function() {jQuery(this).find('.tooltip').stop().fadeTo(300, 1);}, function() {jQuery(this).find('.tooltip').stop().fadeTo(300, 0);});
jQuery('#product-2').hover(function() {jQuery(this).find('.tooltip').stop().fadeTo(300, 1);}, function() {jQuery(this).find('.tooltip').stop().fadeTo(300, 0);});
jQuery('#product-3').hover(function() ....etc. etc.

now i know the code below is not right, i've multiple way to fix..

[Code]....

View 6 Replies View Related

Concatenate To A String 2 Variables?

Jul 23, 2010

i'm trying to concatenate to a string 2 variables that i'm adding together but i'm getting Nan as the result

what am i doing wrong?
str_amount=parseInt(document.getElementById('amount').value);
strfeeamount=parseInt(document.getElementById('feeamount').value);
urltoajax=urltoajax + '&amount=' +str_amount +strfeeamount

View 6 Replies View Related

Refer To An Object Not Yet In Loaded?

Jun 6, 2002

How do you refer to an object such as a drop down <select> box before the <select> box appears in the code....

View 1 Replies View Related

Substring A Value For Display And Concatenate For Validation?

Feb 28, 2006

I have a validation script for upc codes which is currently working for
values that are entered into one text box. I've been asked to break up
the text box into 3 separate fields to accept the 1st digit, middle 10
digits, then last check digit. What I'm doing is substringing the
initial values then concatenating them. What I'm not sure of is, how to
handle the validation. I was previously firing an onBlur after the text
box but now that I have three, and I need the values to concatenate
into one for the validation. Should I just fire a function after the
3rd field that concatenates the 3 values, then pass that value to the
validation function? Or is there a better way?

I was also wondering if there was something I could find like an input
mask, but something that could just "overlay" on top of a regular text
box with one value which could give the appearance of having
separations for certain digits, in this case the first and last.

View 1 Replies View Related

JQuery :: Concatenate Two Strings Or Variables?

Jul 27, 2011

i have the following code:

var myHeight = $(".sidebar").outerHeight(true); /* returns Height */
alert(myHeight); /* returns an integer e.g. 500 */
var addPixels = "px"; /* String variable with value "px" */
$(".text").css({"padding-bottom":myHeight}); /* myHeight = 500 NOT 500px */

[Code]....

View 4 Replies View Related

Refer To An Event Without Using Inline Scripting?

Dec 7, 2011

I am trying to re-write a script that I found on w3schools. The script should check whether ALT key was pressed or not. My objective is not to use any inline scripts and to refer to the event within a function. My script is not working.

<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">[code].......

View 5 Replies View Related

How To Refer To The Original Parent Page

Nov 23, 2004

I have a regular html page called a.html
this page opens a modal dialog window called modal1.html
modal1.html contains a 'Next' button.
when the button is pressed the modal1.html is replaced with modal2.html

modal2.html contains another button.
when its button is pressed, the modal dialog window should close and the location of the original page a.html should change.
I am trying to do something like:

//window.parent.location.href = 'anotherPage.html'
window.opener.location.href = 'anotherPage.html'
window.close();

I cannot use window.opener in modal2.html because its opener is actually modal1.html.
In fact anotherPage.html is opened in a whole new browser page

How can I refer to a.html in this chain?

View 6 Replies View Related

Jquery :: Refer To Li Element Over Which Mouse Is?

Apr 10, 2011

I attach a mouseover event to a ul. Within the function I can use $(this) or this to refer to the ul.How can I refer to the li element over which the mouse is? And therefore make use of event delegation in jQuery.

View 8 Replies View Related

Concatenate Two Fields Show Results To 3rd Field

Feb 27, 2006

what I would like to do is concatenate two fields and assign the results to a 3rd field.

Essentially:

Field1="Joe"
Field2="Smith"

Field3="Joe Smith"

View 1 Replies View Related

Concatenate Two Prompts And Display The Result In An Alert Box

Mar 29, 2010

I am going to concatenate these 2 input values together and display the result in an alert box. These two input are from two prompts.

[Code]...

View 1 Replies View Related

Import A Text File - Give The Variable ContentString Its Text From A Hosted Text File In A Similar Manner

Sep 30, 2010

I have some Javascript which says this:

Now that is fine when the text is only one line long. Suppose it's longer? What I want to do is have Javascript give the variable contentString its text from a hosted text file in a similar manner to the way Javascript can insert more Javascript using a hosted .js file.

I illustrate what I need to do using some "dummy" javascript:

View 2 Replies View Related

JQuery :: Refer To Object's Property Inside $.each()

May 19, 2009

function JGallery(){
this.name="defaultGallery";
this.images=[{//some JSON here}]
this.render=function(){

[Code].....

I've tried to debug it in firebug, but I guess there is a problem with the scope of the 'this'. The 'this' in

//i want append div with id of the name property of jgallery class
$("<div></div>").appendTo("#container").attr("id",this.name);
seems to refer to the iterator in the $.each().

I've tried to do this.this.name but it still doesn't work. Is there any way to allow me access the property of the Jgallery class?

View 3 Replies View Related

Onclick Refer To Parent Object Method ?

May 12, 2010

I am creating an application that uses as much Object Oriented code as I could (mostly to learn it).

I have an object called 'photo' that contains two Image() objects 'fullImage' and 'thumbnail'. All is fine and dandy, I can read the thumbnail and the full image, and their associated properties just fine.

But what I can't seem to do is make the thumbnail's onclick event refer to one of the object's methods.

Here is a greatly simplified version of the object's code.

Code:

So, the thumbnails div gets populated with the thumbnails fine. But for the life of me, I cannot figure out how to make the onclick call the photo object's "editPhoto" method.

Will the way that I am creating the objects using the same name for each one, result in only the last one created being accessible. If so, do I need to create an array of objects so I can uniquely identify each one?

View 3 Replies View Related

Jquery :: Syntax To Use ID Passed In Parameter Refer To DIV

Dec 24, 2009

I'm passing the id of a div as a parameter. I'm not sure how to refer to it with Jquery. The following does not work:
Code:
function updatemail(param1, param2) {
$("#param2").animate({ opacity: "show" }, 300);
}
I also tried $(param2) but it did not work.

View 2 Replies View Related

Refer To The Value Stored In A Dynamically Generated Dropdown

Aug 3, 2010

I have a dropdown which is being dynamically generated within the cfloop query.

<select name="ResourceType#ctr#" onchange="GenRWType(this.name,0)">
<option value="">None</option>
<cfloop query="getResourceType">
<option value="#getResourceType.Resourcetypeid#">#getResourceType.Resourcetype#</option>
</cfloop>
</select>

I am calling the JS function GenRWType which is carrying the name of the dropdown.....the issue is how do I get the value of the selected option from dropdown ? This is the code I have and it does not recognize "rname"

[Code]...

View 4 Replies View Related

JQuery :: How To Refer Nested Field In Multidimensional Array

Sep 8, 2011

I'm using getJSON to retrieve information from a header record and the corresponding detail records and display the detail records in a table. The PHP script that is called returns a JSON string (via json_encode) that looks like this:

{
"srn":"1",
"invNo":"1",
"custNo":"39750",
"purchOrd":"PO12345",
"shipVia":"our truck",
"jobNo":"E001-11",
"invDate":"8/3/2011",
"taxCode":"1000000",
"shpName":"testName", .....

Here is the html table:
<table><thead><tr>
<th colspan="2" >Item Description</th>
<th>Quantity</th>
<th>U/M</th>
<th>Item Price</th>
<th>Item Amount</th>
</tr></thead><tbody>
<tr class="p_row_1"> .....

And here is the $.getJSON:
$.getJSON("GET_INV_INFO.php",{srn:'<?php echo $srn; ?>'},function(s){
// Get Header Info
$('#ip_invNo').html(s.jobNo);
$('#ip_invDate').html(s.invDate);
$('#ip_custNo').html(s.custNo);
$('#ip_purchOrd').html(s.purchOrd);
$('#ip_custName').html(s.custName); .....

My problem comes in the getJSON section where I'm trying to populate the table with a record. I don't know how to refer to the different fields in array 's'. I've tried the following and many variations, but to no avail:
$('.p_row_'+i+':nth-child(1)').html(s.row.i.itemNo);
$('.p_row_'+i+':nth-child(1)').html(s.row[i].itemNo);
How do I refer to a nested field in a multidimensional array like this?

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved