First Timer - Form Variable

Feb 8, 2006

I'm writing some javascript functions to process variables from a form. Running into a few hitches, wonder if anyone can clarify what I think must be pretty easy questions but my searches don't find any answers....

My html page is using the form variable values to do some calculations and display images in a new window.

One of the form objects is a <select> looking like this:
<form name="imgform">
<select name="imgct">
<option value=totalimgs selected>all
<option>3
<option>4
<option>5
.
.
.
</select>

and I want the selected option "all" to be loaded with the value of a predeefined variable "totalimgs". When I later access it using

var imgct=document.imgform.imgct.value;

The above obviously returns a string value of "totalimgs", not the value of the variable itself.

View 3 Replies


ADVERTISEMENT

Variable To Form Hidden Variable's Value

Nov 14, 2010

I have a javascript in the head of the document which has a variable named "ref2" ... ref2 is already working as I can see its value working in another function. I need to send this variable as the value of a hidden field in the form which is in the body of the document.

This is my JavaScript Code:

Code:

And at the end of my form, before the submit button, I have the following code:

Code:

When I execute the form, it doesn't work the way it should, plus, gives me a word "undefined" next to the "Submit" button .....

View 1 Replies View Related

Variable To Form Hidden Variable's Value?

Nov 14, 2010

I have a javascript in the head of the document which has a variable named "ref2" ... ref2 is already working as I can see its value working in another function.I need to send this variable as the value of a hidden field in the form which is in the body of the document.This is my JavaScript Code:

function WriteContactFormStatement1 () {
var ContactFormValue = ref2;
document.write('<input type="hidden" name="UReferrersName" value="' + ContactFormValue + '"

[code]....

View 2 Replies View Related

Accessing A Variable Through A Form Name

Jul 23, 2005

I have 2 arrays:

var A1 = new Array();
A1[ 0 ] ="Y2";

var B1 = new Array();
B1[ 0 ] ="Y1";
B1[ 1 ] ="sink";

I also have a drop down menu with the names of the arrays. Say:

document.form.option[1].text returns 'B1'

Can I transform the string 'B1' into the array B1, so that:

document.form.option[1].text[1] returns 'sink'

Currently I'm doing this with conditionals, e.g.

if(document.form.option[1].text =="B1){do stuff}

but this gets a bit messy.

View 2 Replies View Related

Referencing Form In Variable?

Feb 10, 2009

i have a simple thing that causes me all sorts of headaches. I have many forms on the same page, and identical items in each form. The same object in each form call the same procedure. So, I'm passing in the form value, such as:

onchange="DoMyFunction('formName');"
and then in the procedure i do:
function DoMyFunction(formname){
document.[formname].object.value='1';
}

Now i have functions like this all over, problem is getting them to work. Once they work, they work fine. But when i add a new one, it can match an old function (except the object being referenced) and it won't work!

Does anyone know the proper way to reference a form in a function?

View 4 Replies View Related

Parsing Form Value To Variable?

May 30, 2010

I am trying to assign a variable using a form value, but it returns as undefined. However, if I directly set em (uncomment them), it works.

Why are my values not working?

<script type="text/javascript">
//lichbloom = 2;
//frostlotus = 5;
lichbloom = document.endlessragevalue.lichbloom.value;

[Code]....

View 5 Replies View Related

Variable As A Form Element Name?

Sep 14, 2007

Is it possible to use variables as the name for a form element e.g.

<script type="text/Javascript">
<html>
<head>
<script type="text/Javascript">
var myvar = 1;
</script>
</head>
<body>
<input name="myvar" type="radio" value="radiobutton" />test
</body>
</html>

I tested the above and looked at the course. The name is shown as "myvar" and not "1", so I guess it didn't work.

View 3 Replies View Related

Use Variable In Form And Then In Another,no Reload?

Dec 25, 2011

I have this form

<form action="" method="post">
Nick : <input name="nick" type="text" />
</form>

[code]...

View 1 Replies View Related

Variable For Form Input?

Sep 23, 2009

This should be an easy one to figure out. Right now I have a function that looks like this:

HTML Code:
function myfunction() {
var field = document.myform.sd;

[code]....

View 2 Replies View Related

Check If A Form Variable Has A Value?

Jun 11, 2011

I need to change the code below so that it will check to see if there is a value for the model variable, its a select dropdown in a form. If there is no value then I don't want the var model to be included in the url part.

I also need to check to see if the var pics is checked (its a checkbox) if its checked then i want to include it, if its not checked then again I need to miss it our from the url part.

Code JavaScript:

View 4 Replies View Related

Passing JS Variable To Form?

Sep 5, 2011

I'm using the Maxmind Geoip database to pull information about the visitor:MaxMind - GeoIP JavaScript Web Service(namely the city and state).I want to use that information to prepopulate one of the fields on my form (say city)

Code:
<input id="awf_field-24855776city" type="text" class="text" name="custom US Address (City)" tabindex="502" />

Anyone have any idea how I can do this? I tried the document.write function and it doesn't output to my value="" field with the correct data

View 2 Replies View Related

Submit A Variable Form Name

Sep 21, 2010

I have a page that submits a form via javascript; however, I wish to submit a variable form name, depending on what button is pressed.

So, pressing button 1 will submit frmGeneral1
Pressing button 2 will submit frmGeneral2
pressing button 3 will submit frmGeneral3 and so on

In my javascript, I have:

And I get an error stating object doesn't support this property or method.

The PrimaryKey is a variable passed to my Validate function, which is what is used to define each form on the page (the page could contain up to 500 forms)

Here is my full javascript code:

Code:

View 1 Replies View Related

Getting Variable From Script To HTML Form

Jan 29, 2011

Here is some code (I did not write) which counts down the minutes allowed on an exam. I want to get the minutes remaining when the user submits the exam and store this in a mysql database. My question is what is the variable which communicates the remaining time? And how do I put it in a form so I can pass it once the user submits?

<script language="JavaScript" type="text/javascript">
k = new Date();
n= k.getMinutes();
k.setMinutes(n+<? echo $minutes; ?>);
TargetDate = k;
BackColor = "palegreen";
ForeColor = "navy";
CountActive = true;
CountStepper = -1;
LeadingZero = true; .....

View 1 Replies View Related

Set A Form Variable When Button Is Clicked?

Jul 6, 2010

Set a form variable when button is clicked

View 1 Replies View Related

Submit Form Variable To Lightbox

Aug 13, 2010

I need to send form variable to a lightbox. What this page suppose to do is user will insert his ID, click Papar ~Display in English, the page will refresh and his examination result will be output in the lightbox. More information on my test page here: [URL] paste 158756873427 into the form and click Papar. That lightbox popup is a remote file so I can paste mysql query in it. Also its not working actually.

I already set the query manually like this:
PHP Code:
$result = mysql_query("SELECT * FROM exam_data WHERE no_KP='158756873427'"); 

What I need is the form from infopendidikan.php to send its variable to the lightbox remote page resultpopup.php. Also you can click on the query popup on the left menu to see the fixed query. resultpopup.php need to retrieve variable from infopendidikan.php.

Anyway this is infopendidikan.php code:
PHP Code:
<?php
//if the "submit"variable does not exist form has not been submitted display initial page
if (!$_POST['submit'])
{ ?> .....
If I can get the result in the lightbox without page refresh that will be more cool. The lightbox I'm using is facebox from [URL].

View 5 Replies View Related

Passing Form Variable Into Script?

Jul 9, 2009

I have combined a user's input with a Craigslist RSS Url in this form:Craigslist RSS URL (missing 1 number to define bedrooms) + User Input Number (this completes the URL)Here is the code:

<form name="test">
<script language="Javascript"><!--
rss1 = "http://losangeles.craigslist.org/search/hhh/sfv?query=2br&minAsk=min&maxAsk=max&bedrooms=";

[code]....

View 6 Replies View Related

How Do I Determine Whether Variable Exists In Form

Jan 19, 2010

How do I determine whether a variable exists in a form. I have a form called "theForm". I want to determine whether the variable "THIRD_PARTY" exists in the form and if it has been set.

View 6 Replies View Related

Passing A Variable Into A PHP Form Field?

Nov 19, 2011

I am new to JS and usually learn by studying code posted online and modify it to have it do what I need. Recently, I used a totaling plugin for an online ordering form which does the below:

item1 qty(user input text) * preset price = total price
item2 qty(user input text) * preset price = total price
item3 qty(user input text) * preset price = total price

[code].....

View 1 Replies View Related

Pass A Variable Into A Html Form?

Sep 9, 2009

I was wondering if anyone knew if you could usea javascript variable in an html form. I made a dateusing javascript (I need the 00/00/0000 format, and only in javascript could I get it).

<script LANGUAGE = "Javascript">
Variable for hours requested
var sday = 8
var checkhour

[Code]....

This is the part of the form where I want to enter it into as the default value

After this point I have no clue what to do. If needed i can post more code as well.

View 3 Replies View Related

How To Pass A Variable Without Submit The Form

Oct 12, 2005

Can I pass a javascript variable to another page without submit the form? I have page1 with the selection and some links. I would like the user to select it without submitting a form, but I can get it from another page when clicking on the link. So I would think about the onChange function may help, but don't know how.

<form name="form">
<select name="list" onChange="somefunction()">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
</form>
<a href="http://somedomain/myurl.asp&option='valueTheUserPick'">click here</a>

View 2 Replies View Related

Form Results Sent To Email Variable

Oct 20, 2005

I am trying to create a page that sends user contact information to the appropriate email address. Depending on where the user lives, say California, the results will be sent to the person assigned to California, such as "bob@mail.com (not a real email address).

Right now, I am only working with three states until I get the page up and running:

California (CA = bob@mail.com)
Texas (TX = mary@mail.com)
New York (NY = john@mail.com)

Also, I need the results sent by the form, not as an actual email. I already have this set up and working. I just need to figure out how to pass the variable. Any suggestions? Code:

View 3 Replies View Related

Global Form Variable Not Working

Apr 4, 2006

I have defined a global variable for a form, but it seems my functions can't access it. The error I get from the Firefox Javascript console tells me that my variable has no properties. Code:

var giftForm = document.forms.uploadGift;

function sendForm() {
giftForm.target = 'main'
giftForm.submit();
window.close();
}

Everything runs without a hitch if I declare the form variable inside the function.

View 2 Replies View Related

How To Insert A Php Var Into A Form Variable Onsubmit?

Apr 20, 2002

I want to time how long it takes one of my form scripts to run _after_ I press the submit button.

My php (to start the 'stopwatch' running) looks like this:
<?
$mt = explode(' ', microtime());
$script_start_time = $mt[1] + $mt[0];
?>

So I want to have an input field that looks like this:

<input type='hidden' name='script_start_time' value='$script_start_time'>

BUT $script_start_time must be populated at the exact moment the submit button is pressed, and not when the page where the form is first visited. Which is why I need a client side solution.

View 2 Replies View Related

Reference A Form Object With Variable?

Nov 30, 2010

I am fairly new to JavaScript, have been using VBscript before and JavaScript comes off a bit illogic...

Anyways, here's what I am trying to do:

function TestFileType(formname) {
fileName=document.[formname].img1.value;

apparently I can't reference a form object like this. What is the correct way of going about it?

View 2 Replies View Related

Submitted A Form With (based On Variable)

Jul 16, 2011

I want to use Javascript to submit one of two forms, "myform" and "myotherform" If the value of TotalMinutes is greater then 0, I want to submit MyOtherForm, if it is 0(empty), I want to submit MyForm The code I am using:

[Code]...

View 1 Replies View Related

Appending Data To A Hidden Form Variable

Jul 23, 2006

another problem im having is appending a value to a string. how come
this function isnt working for me? string overwrites the value of
content not gets added onto the end of it?!

function alertchange(value) {
var string = value;
document.update.content.value = document.update.content.value + string;
}

View 1 Replies View Related







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