472,374 Members | 1,543 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

dynamic form needs to be static

Hi,
I am working on a project where I have to make a form list static,
i.e. put in links so that users can choose a local file. As it stands,
it's looking for a php file. Here's an example of the body code:

<select name="standardcode" size="10"
onchange="document.reqForm.submit()" tabindex="4">
<option value="0" SELECTED>-- Select a
Standard--</option>
<option value= >Alabama</option>

And here's the code in the head:

function doSubmit( fm, bn ) {
document[fm].button.value = bn;
document[fm].submit();
}

How do I rewrite this form code so that a user can scroll down the
menu, select a state, and have it link to another page on the site?

Any help is MUCH appreciated!!
Jul 23 '05 #1
3 1709
In article <b6**************************@posting.google.com >, chez4
@pacbell.net enlightened us with...

<select name="standardcode" size="10"
onchange="document.reqForm.submit()" tabindex="4">
<option value="0" SELECTED>-- Select a
Standard--</option>
<option value= >Alabama</option>
So, the form submits when a user selects a state.
(note that the code you showed in the head does not fire here)

How do I rewrite this form code so that a user can scroll down the
menu, select a state, and have it link to another page on the site?


Just change the action in the form tag to the proper page. Myself, I'd
change it to a php page and have that page do the work depending on
state. Since a form was submitted, the value of that select would be
available.

But, if you wanted that page to vary depending on the state and just
want to use script, you'd need further adjustments.

<select name="standardcode" size="10"
onchange="go(this.options[selectedIndex].value)" tabindex="4">
<option value="0" SELECTED>-- Select a State--</option>
<option value='AL'>Alabama</option>

function go(val)
{
// val is the state like AL
if (val == '0')
{
alert ("You must choose a state.");
return;
}

if (val == 'AL') window.location =
'http://www.server.com/somePage.php';
else if (val == 'IL' ) window.location =
'http://www.server.com/someotherPage.php' ;
// etc
}

HTH
--
--
~kaeli~
If you don't pay your exorcist, you get repossessed.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Nancy, copy/paste the code below.

Orlando, aka, Cycloneous

<HTML>
<HEAD>

<TITLE>JavaScript</TITLE>
<script language = "javascript" type="text/javascript">

function doSubmit() {

var i = document.regForm.standardcode.selectedIndex;
var url = document.regForm.standardcode.options[i].value;

// first option
// comment to unactivate

document.regForm.action = url;
document.regForm.submit();

// second option
// uncomment to activate

// location.href = url;

}

</script>
</HEAD>

<BODY>
<form name = "regForm">
<select name="standardcode" size="10" onChange="doSubmit();" tabindex="4">
<option value="0" SELECTED>-- Select a Standard--</option>
<option value="http://www.reuters.com/">Reuters News</option>
<option value="http://www.engr.uconn.edu/">UConn</option>
<option value="http://home.netscape.com/">Netscape</option>
<option value="http://www.cnn.com/">CNN</option>
</select>

</BODY>
</HTML>
Jul 23 '05 #3
Hi Cycloneous Echevarria,

Thanks for your help. I tried your suggestion, but I still can't get my
page to work. (I don't know javascript!). Here is all the script in the
head.
I pasted your script in at the bottom.
<SCRIPT language="JavaScript" TYPE="text/javascript">
<!--

var NSWindows;
var is = new Object();
is.agent = navigator.userAgent.toLowerCase();
is.ie55 = (is.agent.indexOf("msie 5.5") != -1);
is.ie6 = (is.agent.indexOf("msie 6") != -1);
is.ns6x = (is.agent.indexOf("netscape6") != -1);
is.moz = (is.agent.indexOf("gecko")!= -1);
is.win = (is.agent.indexOf("win") != -1);
function NSWindowOpen(path, winName, dimensions, scrollbars,
toolbar, properties, loc_left, loc_top) {
if (NSWindows == null) {
NSWindows = new Array();
}
var index = NSWindows.length;
for (var i = 0; i < NSWindows.length; i ++) {
if (NSWindows[i] == null) {
index = i;
break;
}
if (winName == null) {
if (NSWindows[i].closed) {
index = i;
break;
}
} else {
if (NSWindows[i].closed) {
index = i;
} else if (NSWindows[i].name == winName) {
NSWindows[i].close();
index = i;
break;
}
}
}
if (winName == null) {
winName = "nswin" + index;
}
if (dimensions == null) {
dimensions = "width=780,height=540";
}
if (properties == null) {
properties = "resizable=yes";
if ((scrollbars == null) || (scrollbars == true)) {
properties += ",scrollbars=yes";
}
if (toolbar == true) {
properties += ",toolbar=yes";
}
} else {
if (properties.indexOf("resizable=") == -1) {
properties += ",resizable=yes";
}
if ((properties.indexOf("scrollbars=") == -1) &&
((scrollbars == null) || (scrollbars == true))) {
properties += ",scrollbars=yes";
}
if ((properties.indexOf("toolbar=") == -1) &&
(toolbar == true)) {
properties += ",toolbar=yes";
}
}
if (loc_left && loc_top) {
properties += ",top=" + loc_top + ",left=" + loc_left;
} else if (loc_left) {
var loc_x = Math.floor((screen.availLeft || 0) + (loc_left / 100 *
screen.availWidth));
var loc_y = Math.floor((screen.availTop || 0) + (loc_left / 100 *
screen.availHeight));
properties += ",top=" + loc_y + ",left=" + loc_x;
}
var offsite = false;
if( (path.indexOf('http') != -1 && path.indexOf('netschools') == -1)
||
path.indexOf('offsite') != -1 ) {
offsite = true;
}
properties += "," + dimensions;
NSWindows[index] = window.open(path, winName, properties);
return false;
}
function NSWindowOpenNoFalse(path, winName, dimensions, scrollbars,
toolbar, properties, loc_left, loc_top) {
NSWindowOpen(path, winName, dimensions, scrollbars, toolbar,
properties, loc_left, loc_top);
}
function NS_openWindow(page) {
NSWindowOpen(page, 'NSWindow', null, null, null,
'menubar=yes');
}

function NS_swapImageSimple( image, pos ) {
document.images[pos].src = image;
}

function MM_openBrWindow(theURL,winName,features) { //
v2.0
if (objWindow && !objWindow.closed){
objWindow.close();
}
objWindow = window.open(theURL,winName,features);
objWindow.focus();
}
function NSbutton_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.NSbutton_p)
d.NSbutton_p=new Array();
var
i,j=d.NSbutton_p.length,a=NSbutton_preloadImages.a rguments; for(i=0;
i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.NSbutton_p[j]=new Image;
d.NSbutton_p[j++].src=a[i];}}
}

function doSubmit() {

****var i = document.regForm.standardcode.selectedIndex;
****var url = document.regForm.standardcode.options[i].value;
****
****document.regForm.action = url;
****document.regForm.submit();

****// second option
****// uncomment to activate
****
****// location.href = url;
****
}

//-->
</SCRIPT>
And here's what's in the body.

<TD CLASS="form-item-label">&nbsp;</TD>
<TD>&nbsp;</TD>
<TD CLASS="form-item"><TABLE BORDER="0" CELLPADDING="0"
CELLSPACING="0" >
<TR>
<TD CLASS="form-item"> Standard</TD>
</TR>
<TR>
<TD>
<form name = "regForm"><select name="standardcode" size="10"
onChange="doSubmit();" tabindex="4">
****<option value="0" selected>-- Select a standard--</option>
<option value="../Teacher/MySchool/Reports/SampleReports/AL/AL
curr cov.htm">Alabama</option>

Can anyone see my problem here?
When I select the state, the htm file will not load.
thanks!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4

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

Similar topics

4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
3
by: CAD Fiend | last post by:
Hello, Well, after an initial review of my database by my client, they have completely changed their minds about how they want their form. As a result, I'm having to re-think the whole process....
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
13
by: Krivenok Dmitry | last post by:
Hello all! Perhaps the most important feature of dynamic polymorphism is ability to handle heterogeneous collections of objects. ("C++ Templates: The Complete Guide" by David Vandevoorde and...
6
by: kode4u | last post by:
How to use python get my windows box's ip setting type? Dynamic ip, or static ip? If it's static ip, what's the exact value?
2
by: 09876 | last post by:
Hi: all I understand the difference between dynamic binding and static binding. But I just wonder what is the point to make the distinction between the dynamic binding and static binding. For...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.