Time:
Scotland: Fri, 10:11 pm
Rhode Island: Fri, 5:11 pm
Florida: Fri, 5:11 pm
New Mexico: Fri, 3:11 pm
California: Fri, 2:11 pm

Click here to visit Livelife365.com

Click here to visit nmdarts.com



Buy this Ad Space.

180px wide.

Please get in touch with KH@ if you are interested and make an offer.

CLICK HERE TO GET AUCTION BAR NOW
US$10 per year - Save $100s!
The Fabulously Unfair
WebX Auction Bar. For Ebay etc.
Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!


More information and sign-up.

WebXpertz Hosting.
Custom fit from $5pm. PHP/MySQL
You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!


Please click here for more information

For continued disscussion on this topic : Error using the "onClick" handler


ecojohnson
09-07-2001, 07:16 PM
I have the following form:

<FORM ACTION="action_page.cfm" METHOD="post" NAME="theform">
Input name: <INPUT TYPE="text" NAME="name" <cfif isdefined("name")>VALUE=<cfoutput>#name#</cfoutput></cfif>>
Input ID: <INPUT TYPE="text" NAME="ID" VALUE="">
<BR><BR>
<INPUT TYPE="button" NAME="Add_ID" VALUE="Add_ID" onClick="window.location='TestForm.cfm?name="+document.theform.name.value+"'">
<INPUT TYPE="button" NAME="Add_ID" VALUE="Clear" onClick="window.location='TestForm.cfm'">
<INPUT TYPE="submit" NAME="Submit_ID" VALUE="Submit">
</FORM>

I don't know if I am doing something wrong, but everytime I try to run this, I get a javascript error: "Unterminated string constant".

The problem lies somewhere in the code for the Add_ID button. If I remove the quotes around the + signs, it works, but then the string is added as the name field, which is not what I want.

Any ideas or tips?

Alexandr
09-07-2001, 11:11 PM
hi ecojohnson

replace this
onClick="window.location='TestForm.cfm?name="+document.theform.name.value+"'">

with this


<INPUT TYPE="button" NAME="Add_ID" VALUE="Add_ID" onClick="window.location='TestForm.cfm?name=this.form.name.value'">


should work

ecojohnson
09-08-2001, 12:20 AM
Hi Alexandr:

Thanks for your response. I cut and pasted your revision into my code and I no longer got an error. Except, it didn't really fix my problem.

Now, when I enter a value (I justed used the word "test") and then select the button, "test" is removed, and is replaced by "this.form.name.value".

I tried adding quotes, and other things and I still couldn't get it to work.

If you have any other ideas, please let me know. Thanks!

Alexandr
09-08-2001, 12:26 AM
simply write function
function golink(name,value)
{
window.location.href = "TestForm.cfm?" + name + "=" + value;
}

and your code
<INPUT TYPE="button" NAME="Add_ID" VALUE="Add_ID" onClick="golink('name', this.form.name.value)">

or you don't want to use a function

ecojohnson
09-08-2001, 12:42 AM
Wow, that worked like a charm. Now I'm depressed. I know so little about JS.

Thanks so much!

Alexandr
09-08-2001, 11:32 AM
something more
yesterday night I was tired and can't give you stright aswer
but it's possible without function

<INPUT TYPE="button" NAME="Add_ID" VALUE="Add_ID" onClick="window.location='TestForm.cfm?name=' + this.form.name.value">

The Gray Wolf
09-09-2001, 01:03 PM
hi all

ecojohnson i noticed in your code <cfif> which i couldnt understand what its doing

your problem as you might already found out that is with the comas ' which is a known prob in js so dont get depressed

but about the <cfif> is someone can explain i will aprricate it

webdesign11
09-09-2001, 02:09 PM
Hey Gray Wolf,

The <cfif> tag is a ColdFusion tag to perform conditional tests. In this instance, it is testing to see if the variable "name" exists. The <cfoutput> tag is used together with the <cfquery> tag. WebMoneky (http://hotwired.com) has some great tutorials on ColdFusion if you want to check them out.

Hope that helps!

Happy coding! :)

The Gray Wolf
09-09-2001, 02:15 PM
thanks :cool:

its always a plassure to learn a few new things

have a cold beer on my expense :p

(if you are in the right age) ;)