473,385 Members | 1,814 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,385 software developers and data experts.

Posting a variable Onclick

Hi

I want to have a text link on my page - say for instance 'javascript' where
clicking on this link would submit a form and also pass a variable name
such as META_Name="javascript" with the form - is there a simple function
to do this ?

Many thanks for any advice
John
Jul 20 '05 #1
3 1395
John <jo********@hotmail.com> wrote in
news:Xn**********************************@195.114. 230.35:
jo********@hotmail.com


Following on from this I've now got this far :
<script>
function searchcategory(category) {
addfield (form1, 'hidden', 'META_Name', category);
document.form1.submit();
}
</script>

<form name="form1" method="post" action ="">
<a href="bla" OnClick="searchcategory('string')">String</A>
</form>

When clicking on string however, I get an Object Expected error on the
addfield line.

Can anyone see the problem or perhaps suggest an easier way ?

Thanks

John
Jul 20 '05 #2
Ivo
"John" <jo********@hotmail.com> wrote
<script>
function searchcategory(category) {
addfield (form1, 'hidden', 'META_Name', category);
document.form1.submit();
}
</script>

<form name="form1" method="post" action ="">
<a href="bla" OnClick="searchcategory('string')">String</A>
</form>

When clicking on string however, I get an Object Expected error on the
addfield line.


I may be missing things, but I am not familiar with a native "addfield"
function. Perhaps you need to write something like this first:
function addfield(formname,fieldname,fieldtype,fieldvalue){
var x=document.createElement('input');
x.type=fieldtype;
x.value=fieldvalue;
document.forms[formname].appendChild(x);
}
and put quotes around form1 to make it read addfield( "form1", etc.)
HTH
Ivo
Jul 20 '05 #3
Thanks Ivo, this works great :)

"Ivo" <no@thank.you> wrote in news:403e75c9$0$63133$a344fe98
@news.wanadoo.nl:
"John" <jo********@hotmail.com> wrote
<script>
function searchcategory(category) {
addfield (form1, 'hidden', 'META_Name', category);
document.form1.submit();
}
</script>

<form name="form1" method="post" action ="">
<a href="bla" OnClick="searchcategory('string')">String</A>
</form>

When clicking on string however, I get an Object Expected error on the
addfield line.


I may be missing things, but I am not familiar with a native "addfield"
function. Perhaps you need to write something like this first:
function addfield(formname,fieldname,fieldtype,fieldvalue){
var x=document.createElement('input');
x.type=fieldtype;
x.value=fieldvalue;
document.forms[formname].appendChild(x);
}
and put quotes around form1 to make it read addfield( "form1", etc.)
HTH
Ivo


Jul 20 '05 #4

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

Similar topics

6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
10
by: Sharon | last post by:
Hi! Does anyone know why the onclick in the following popup menu gives the error:"Val is undefined"? Does it have something to do with the fact that it is called within the variable tablePop?...
3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
2
by: umashd | last post by:
Hi, I am doing a web based project for my graduation. I studied bit of java for backend processesing and javascript for the client. Here is the scenario. In the FORM, I use INPUT TYPE=text...
4
by: rbutch | last post by:
hey guys, i may be totally in left field on this, but i'll try to explain. using a web form and VB.net. a simple text box control. and added an 'onclick' event to bring up another aspx form with...
1
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
0
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
5
by: Daz | last post by:
Hi everyone. Another simple question which should hopefully warrent a simple answer. I would like a function to be run whenever a variable is updated. I have tried binding the onchange event...
6
by: Jeremy Felt | last post by:
Newbie here. I'm sure I'm missing something EXTREMELY simple, but an hour of searching has led to nothing. I'm playing around with ajax and trying to pass a variable to a function. If I do:...
1
by: Jorge | last post by:
On Sep 28, 9:55 am, De_Dood <TimD...@gmail.comwrote: 'creationTime' is not a variable, but a property of 'div1'. Yes, that's the way it's suppossed to be. When you click on a 'div', 'this'...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.