473,372 Members | 851 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Very simple javascript problem

I have a function that is passed a id number called templateid. The value is
an identifer of a form element.
To get the value I want I would use the following

form1.template8.value

In the function I need to get the templateid (which is 8) and get it to
display the value of template8 etc

How do i do this??

function createpage_onclick(templateid)
{
// the templateid 8
// needs to get the value of the form element template8

alert( What goes here!!!);
}

Thanks

Chris Hughes
Jul 20 '05 #1
3 1664
"Chris Hughes" <ch*****************@hotmail.com> wrote in message
news:3f*********************@mercury.nildram.net.. .
I have a function that is passed a id number called templateid. The value is an identifer of a form element.
To get the value I want I would use the following

form1.template8.value

In the function I need to get the templateid (which is 8) and get it to
display the value of template8 etc

How do i do this??

function createpage_onclick(templateid)
{
// the templateid 8
// needs to get the value of the form element template8

alert( What goes here!!!);
}


Something like this?

function createpage_onclick( templateid ) {
elementId = "template" + templateid;
oFormElement = document.getElementById( elementId );
// Alert the value
alert( oFormElement.value );
}
Also, I'm curious as to what context you are calling this function in - eg.
where do you get the 'templateid' from when you call the function?
Jul 20 '05 #2
"Chris Hughes" <ch*****************@hotmail.com> wrote in message
news:3f*********************@mercury.nildram.net.. .
I have a function that is passed a id number called templateid.
The value is an identifer of a form element.
To get the value I want I would use the following

form1.template8.value

In the function I need to get the templateid (which is 8) and
get it to display the value of template8 etc

How do i do this??

function createpage_onclick(templateid)
{
// the templateid 8
// needs to get the value of the form element template8

alert( What goes here!!!);
}


<URL: http://www.jibbering.com/faq/#FAQ4_39 >

Richard.
Jul 20 '05 #3
"Chris Hughes" <ch*****************@hotmail.com> writes:
I have a function that is passed a id number called templateid. The value is
an identifer of a form element.
To get the value I want I would use the following

form1.template8.value

In the function I need to get the templateid (which is 8) and get it to
display the value of template8 etc


document.forms['form1'].elements['template'+templateid].value

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Keiron Waites | last post by:
Ok to understand what I'm doing you'll have to load the HTML file attached (code also below): When you select an item on the left and select the ">>" button, some alerts will come up telling you...
11
by: Frag | last post by:
Hi guys, I searched around without any clear answer. Tons of stuff, but nothing concrete. I am trying to call this Javascript function: function ButtonClicked() { alert("The button has...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
6
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine,...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
3
by: modermo | last post by:
Hey new to javascript figuring out how to fix this darn problem. I employ an image rollover, and it works beautifully in safari. But in firefox, the image has an annoying blue border around...
4
by: Chris Zopers | last post by:
Hello, We're developing an ASP.NET / C# intranet application. All users use Internet Explorer 6.0 and JavaScript is always enabled. In a HTML table, we use an onclick event on each tablerow...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
18
by: Daniel Orner | last post by:
Hi all, I've been trying to pin down a memory leak in IE6 for several WEEKS now. I've done my share of googling etc., and know all about common leaks like circular references and closures, but...
5
by: Ibys | last post by:
Hi, i am just starting to learn javascript, so i am probably doing something very simple wrong. i have read a lot of articles on maths in java, but cant find anything simple enough for my problem. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.