...

View Full Version : basic help with a submit button



theexo51
07-05-2005, 06:11 PM
you guys have made my day easy so far..

the next logical step...

so i select the data from the combo boxes, then type in any extra data. i now want to press submit and save the data from these boxes and text box onto a new page as a link, so that i can click on it and it will bring up the information.

all of this is so far above my head its making feel dizzy! but im getting there with a little help

thanks in advance

(oh, and if anyone has a good source to learn JS and possibly html i would love to know, i am starting at the very beginning but need to know this stuff for my new job - books or websites or anything else thats handy for learning)

Mr J
07-05-2005, 10:52 PM
Showing us your code would be extremely helpful here

theexo51
07-06-2005, 10:01 AM
ok, sorry bout that... if there is a tidyer way to do this then let me know.

ps, i would also like the alert to come up after clicking submit too
Thanks for any help!

<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option selected>---Company-------------</option>
<option>company x</option>
<option>company y</option>
<option>company z</option>
</select>

<select name="stage2" size="1" onChange="redirect1(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Location-------------</option>
<option value=" " selected>---Location--------------</option>
</select>

<select name="stage3" size="1" onChange="redirect2(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Person----------------</option>
<option value=" " selected>---Person----------------</option>
</select>

<script>
<!--



var groups=document.isc.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()

group[0][0]=new Option("---Location---"," ");

group[1][0]=new Option("---Location---"," ");
group[1][1]=new Option("a"," ");
group[1][2]=new Option("b"," ");
group[1][3]=new Option("c"," ");
group[1][4]=new Option("d"," ");
group[1][5]=new Option("e"," ");
group[2][0]=new Option("---Location---"," ");
group[2][1]=new Option("a"," ");
group[3][0]=new Option("---Location---"," ");
group[3][1]=new Option("a"," ");
group[3][2]=new Option("b"," ");
group[3][3]=new Option("c"," ");
group[3][4]=new Option("d"," ");


var temp=document.isc.stage2


function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
redirect1(0)
}



var secondGroups=document.isc.stage2.options.length
var secondGroup=new Array(groups)
for (i=0; i<groups; i++) {
secondGroup[i]=new Array(group[i].length)
for (j=0; j<group[i].length; j++) {
secondGroup[i][j]=new Array() }}

secondGroup[0][0][0]=new Option("---Person---"," ");
secondGroup[1][0][0]=new Option("---Person---"," ");
secondGroup[1][1][0]=new Option("---Person---"," ");
secondGroup[1][1][1]=new Option("1");
secondGroup[1][1][2]=new Option("2");
secondGroup[1][1][3]=new Option("3");
secondGroup[1][1][4]=new Option("4");

secondGroup[1][2][0]=new Option("---Person---"," ")
secondGroup[1][2][1]=new Option("1");
secondGroup[1][2][2]=new Option("2");
secondGroup[1][2][3]=new Option("3");
secondGroup[1][2][4]=new Option("4");

secondGroup[1][3][0]=new Option("---Person---"," ")
secondGroup[1][3][1]=new Option("1");
secondGroup[1][3][2]=new Option("2");
secondGroup[1][3][3]=new Option("3");
secondGroup[1][3][4]=new Option("4");

secondGroup[1][4][0]=new Option("---Person---"," ")
secondGroup[1][4][1]=new Option("1");
secondGroup[1][4][2]=new Option("2");
secondGroup[1][4][3]=new Option("3");
secondGroup[1][4][4]=new Option("4");

secondGroup[2][0][0]=new Option("---Person---"," ");
secondGroup[2][1][0]=new Option("---Person---"," ");
secondGroup[2][1][1]=new Option("1t");
secondGroup[2][1][2]=new Option("2");
secondGroup[2][1][3]=new Option("3");
secondGroup[2][1][4]=new Option("4");

secondGroup[3][0][0]=new Option("---Person---"," ");
secondGroup[3][1][0]=new Option("---Person---"," ");
secondGroup[3][1][1]=new Option("1");
secondGroup[3][1][2]=new Option("2");
secondGroup[3][1][3]=new Option("3");
secondGroup[3][1][4]=new Option("4");

secondGroup[3][2][0]=new Option("---Person---"," ");
secondGroup[3][2][1]=new Option("1");
secondGroup[3][2][2]=new Option("2");
secondGroup[3][2][3]=new Option("3");
secondGroup[3][2][4]=new Option("4");

secondGroup[3][3][0]=new Option("---Person---"," ");
secondGroup[3][3][1]=new Option("1");
secondGroup[3][3][2]=new Option("2");
secondGroup[3][3][3]=new Option("3");
secondGroup[3][3][4]=new Option("4");

secondGroup[3][4][0]=new Option("---Person---"," ");
secondGroup[3][4][1]=new Option("Server");




var temp1=document.isc.stage3
function redirect1(y){
for (m=temp1.options.length-1;m>0;m--)
temp1.options[m]=null
for (i=0;i<secondGroup[document.isc.example.options.selectedIndex][y].length;i++){
temp1.options[i]=new Option(secondGroup[document.isc.example.options.selectedIndex][y][i].text,secondGroup[document.isc.example.options.selectedIndex][y][i].value)
}
temp1.options[0].selected=true
}

function redirect2(z){
alert("Error Logged")
}

//-->
</script>

</td>
</tr>

</table>
<br>
<br>
<br>
<table align="center" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td nowrap height="11"> &nbsp;
<form name="myForm" method="post">
<input type="text" name="myTextInput" size="40">
<input type="submit" value="Submit" name="B1">
</form>
</td>
</tr>
</table>

</FORM>

Mr J
07-06-2005, 11:19 AM
Try this out to start with.

Your script is a bit confusing because sometimes you are referencing the option text and in other instances the option value whilst only creating the option text, I think, unless its me thats getting confused ...........



<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script type="text/javascript">
<!--

function init(){
groups=document.isc.example.options.length
group=new Array(groups)
for (i=0; i<groups; i++){
group[i]=new Array()
}

group[0][0]=new Option("---Location---"," ");

group[1][0]=new Option("---Location---"," ");
group[1][1]=new Option("a"," ");
group[1][2]=new Option("b"," ");
group[1][3]=new Option("c"," ");
group[1][4]=new Option("d"," ");
group[1][5]=new Option("e"," ");

group[2][0]=new Option("---Location---"," ");
group[2][1]=new Option("a"," ");

group[3][0]=new Option("---Location---"," ");
group[3][1]=new Option("a"," ");
group[3][2]=new Option("b"," ");
group[3][3]=new Option("c"," ");
group[3][4]=new Option("d"," ");


temp=document.isc.stage2
secondGroups=document.isc.stage2.options.length
secondGroup=new Array(groups)
for (i=0; i<groups; i++) {
secondGroup[i]=new Array(group[i].length)
for (j=0; j<group[i].length; j++) {
secondGroup[i][j]=new Array()
}
}

secondGroup[0][0][0]=new Option("---Person---"," ");
secondGroup[1][0][0]=new Option("---Person---"," ");
secondGroup[1][1][0]=new Option("---Person---"," ");
secondGroup[1][1][1]=new Option("1");
secondGroup[1][1][2]=new Option("2");
secondGroup[1][1][3]=new Option("3");
secondGroup[1][1][4]=new Option("4");

secondGroup[1][2][0]=new Option("---Person---"," ")
secondGroup[1][2][1]=new Option("1");
secondGroup[1][2][2]=new Option("2");
secondGroup[1][2][3]=new Option("3");
secondGroup[1][2][4]=new Option("4");

secondGroup[1][3][0]=new Option("---Person---"," ")
secondGroup[1][3][1]=new Option("1");
secondGroup[1][3][2]=new Option("2");
secondGroup[1][3][3]=new Option("3");
secondGroup[1][3][4]=new Option("4");

secondGroup[1][4][0]=new Option("---Person---"," ")
secondGroup[1][4][1]=new Option("1");
secondGroup[1][4][2]=new Option("2");
secondGroup[1][4][3]=new Option("3");
secondGroup[1][4][4]=new Option("4");

secondGroup[2][0][0]=new Option("---Person---"," ");
secondGroup[2][1][0]=new Option("---Person---"," ");
secondGroup[2][1][1]=new Option("1t");
secondGroup[2][1][2]=new Option("2");
secondGroup[2][1][3]=new Option("3");
secondGroup[2][1][4]=new Option("4");

secondGroup[3][0][0]=new Option("---Person---"," ");
secondGroup[3][1][0]=new Option("---Person---"," ");
secondGroup[3][1][1]=new Option("1");
secondGroup[3][1][2]=new Option("2");
secondGroup[3][1][3]=new Option("3");
secondGroup[3][1][4]=new Option("4");

secondGroup[3][2][0]=new Option("---Person---"," ");
secondGroup[3][2][1]=new Option("1");
secondGroup[3][2][2]=new Option("2");
secondGroup[3][2][3]=new Option("3");
secondGroup[3][2][4]=new Option("4");

secondGroup[3][3][0]=new Option("---Person---"," ");
secondGroup[3][3][1]=new Option("1");
secondGroup[3][3][2]=new Option("2");
secondGroup[3][3][3]=new Option("3");
secondGroup[3][3][4]=new Option("4");

secondGroup[3][4][0]=new Option("---Person---"," ");
secondGroup[3][4][1]=new Option("Server");

}


function redirect1(y){
temp1=document.isc.stage3
for (m=temp1.options.length-1;m>0;m--)
temp1.options[m]=null
for (i=0;i<secondGroup[document.isc.example.options.selectedIndex][y].length;i++){
temp1.options[i]=new Option(secondGroup[document.isc.example.options.selectedIndex][y][i].text,secondGroup[document.isc.example.options.selectedIndex][y][i].value)
}
temp1.options[0].selected=true
}

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
redirect1(0)
}

function redirect2(z){
//alert("Error Logged")
}


function test(){

str1=document.isc.example.options[document.isc.example.selectedIndex].text
str2=document.isc.stage2.options[document.isc.stage2.selectedIndex].text
str3=document.isc.stage3.options[document.isc.stage3.selectedIndex].text
str4=document.isc.myTextInput.value

//alert(str1+str2+str3+str4+".htm")
document.getElementById("qw").innerHTML=str1+str2+str3+str4+".htm"
return false
}

//-->
</script>

</HEAD>
<BODY onload="init()">

<form name="isc" onsubmit="return test()">
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option selected>---Company-------------</option>
<option>company x</option>
<option>company y</option>
<option>company z</option>
</select>

<select name="stage2" size="1" onChange="redirect1(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Location-------------</option>
<option value=" " selected>---Location--------------</option>
</select>

<select name="stage3" size="1" onChange="redirect2(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Person----------------</option>
<option value=" " selected>---Person----------------</option>
</select>


</td>
</tr>

</table>
<br>
<br>
<br>
<table align="center" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td nowrap height="11"> &nbsp;
<input type="text" name="myTextInput" size="40">
<input type="submit" value="Submit" name="B1">
</td>
</tr>
</table>
</FORM>

<div id="qw"></div>


</BODY>
</HTML>

theexo51
07-06-2005, 02:29 PM
:D thats cool..this is the most helpful site on the net i think.

i suppose the couple of things i would like are:

1) have the alert linked to the submit button. <-- YEAH i figured this myself...thank you, thank u very much ;)
2) i will create a new page called "Logs.htm" or something and on pressing submit have the form data stored there, not below the boxes.
3) and is it possible to have the text box wrap and not carry on along, so that if the length of the text is longer than the box it goes down to a second line.

THANKS A LOT !! :D

tehbau
07-06-2005, 06:25 PM
Javascript Bible 5th Edition has come in handy for me so far. :)

Mr J
07-06-2005, 07:21 PM
and is it possible to have the text box wrap and not carry on along, so that if the length of the text is longer than the box it goes down to a second line.


For something that long you should concider using a textarea box

theexo51
07-07-2005, 10:29 AM
thanks guys, i have looked at that java bible, think i will have to twist my managers arm to buy it for me.

ok, so i have put a text area in - much more suitable - now i need to press submit and store the data on a page called logpage.htm.

mr J has managed to get it to paste the data on the same page but thats not 100% really what i want...

i can see the code that is used but so far havent managed to replicate it in storing the data to a different page...any ideas mr j?

theexo51
07-07-2005, 11:34 AM
just one more thing, i have just noticed that if i enter more than one set of data, the submit function puts the data over the top, i would like to know if its possible to put the data on as a list in date order with the newest at the top?

any advice would be greatly recieved

Mr J
07-07-2005, 12:00 PM
If the data is to be permanently stored in logpage.htm then you are going to need PHP

theexo51
07-07-2005, 12:18 PM
yer i guess thats what i want from them...

if i explain, each person in the array has their own webpage which will slowly fill up with the logs of the problems...then from looking at those pages i can see when calls where logged and also what the problem was.

so, php huh, another thing to get me head around! :eek:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum