/    Sign up×
Community /Pin to ProfileBookmark

Please solve the following problem

Hello All
I have changed other page to fit my demand in the following codes ,as you see below we have a function named addrepair which it had given the valur of number argument from the number field that user enter for example 2 or 3 ,Now I want to change it I want to pass the number to the addrepair function according the number I choose from the select box(“component_select) for example if I choose component_1 and component_2 and component_4 it pass 3 to the function addrepair
Sincerley Mohsen

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<SCRIPT language=JavaScript>
<!– This script is written by Speedpete. –>
<!– You may copy it freely –>

function addRepair(number) {
data = “”;
inter = “‘”;

if (number < 17 && number > -1) {

for (i=1; i <= number; i++){

displaycount = i + 1;

//because a seperate table didn’t work, a lot of spaces are needed
data = data + “<strong>Repair ” + displaycount + “</strong>&nbsp;&nbsp;<select name=repairtype” + displaycount + ” id=repairtype” + displaycount + ” align=’top’><option value=’12’>Alignment</option><option value=’5′>Battery</option><option value=’13’>Brakes</option><option value=’10’>Maintainence</option><option value=’9′>Major Repair</option><option value=’8′>Minor Repair</option><option value=’2′>Oil</option><option value=’3′>Oil Change</option><option value=’14’>Other</option><option value=’11’>State Inspection</option><option value=’4′>Tires</option><option value=’6′>Tune Up</option><option value=’7′>Washing</option></select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>Qty @ Cost</strong><input name=’quantity” + displaycount + “‘ type=’text’ size=’6′ maxlength=’6′ align=’top’> @ <input align=’top’ name=’repaircost” + displaycount + “‘ type=’text’ id=’repaircost” + displaycount + “‘ size=’10’ maxlength=’10’><BR>”;
}

finalcount = displaycount;
data = data + “<input type=hidden name=repaircount id=repaircount value=” + finalcount + “>”;

if (document.layers) {
document.layers.repairlist.document.write(data);
document.layers.repairlist.document.close();
}

else {
if(document.getElementById) {
document.getElementById(‘repairlist’).innerHTML = data;
}
else {
return;
}
}
}
else {
window.alert(“There’s a maximum of 15 entries.”)
}
}
</SCRIPT>

</head>
<META content=”MSHTML 5.00.2920.0″ name=GENERATOR>

<body>
Add Expense

<P><STRONG>Howmany Rent option Do you have?</STRONG></P>
<FORM id=counter name=counter>
<p>

<SELECT multiple name=”component-select”>

<OPTION>Component_3</OPTION>
<OPTION>Component_4</OPTION>
<OPTION>Component_5</OPTION>
<OPTION>Component_6</OPTION>
<OPTION>Component_7</OPTION>

</SELECT>
</p>

&nbsp;&nbsp;
<INPUT onclick=addRepair(counter.number.value) type=button value=”Set Number”>
</FORM>
<FORM action=/expenses_processor.cfm method=post name=addedit
onsubmit=”return _CF_checkaddedit(this)”>

<STRONG>Rent price</STRONG>&nbsp;
<input
name=repairtype1 type=hidden value=1> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<STRONG>Qty
@ Cost</STRONG> <INPUT align=top maxLength=6 name=quantity1 size=6>
@
<INPUT align=top id=repaircost1 maxLength=10 name=repaircost1
size=10> <BR>

<DIV id=repairlist style=”POSITION: relative”
name=”repairlist”></DIV>

<INPUT name=Submit type=submit value=”Add Repair”> &nbsp;&nbsp;&nbsp;&nbsp;
<INPUT name=reset type=reset value=”Clear Form”>

</FORM>

</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@NevermoreApr 20.2003 — Can you rephrase that?
Copy linkTweet thisAlerts:
@mohsenaauthorApr 20.2003 — thank you

I discussed with one of coldfusion programmer guyand he finally solved my problem( he is one of the best coldfusion programmer) now here the code:<cfquery name="Branch" datasource="real_state">

select DISTINCT Branch

from dbo.Branches

</cfquery>

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<SCRIPT language=JavaScript>

<!-- This script is written by Speedpete. -->

<!-- You may copy it freely -->

function addRepair() {
var data = "";

var inter = "'";

var number=0;

for (i=0; i < document.forms[0].Branch.length;i++) {

if (document.forms[0].Branch.options[i].selected == true) {

number=number + 1;

}

}





if (number < 17 && number > -1) {

for (i=1; i <= number; i++){

displaycount = i + 1;

data = data + "<strong>Repair " + displaycount + "</strong>&nbsp;&nbsp;<select name=repairtype" + displaycount + " id=repairtype" + displaycount + " align='top'><option value='12'>Alignment</option><option value='5'>Battery</option><option value='13'>Brakes</option><option value='10'>Maintainence</option><option value='9'>Major Repair</option><option value='8'>Minor Repair</option><option value='2'>Oil</option><option value='3'>Oil Change</option><option value='14'>Other</option><option value='11'>State Inspection</option><option value='4'>Tires</option><option value='6'>Tune Up</option><option value='7'>Washing</option></select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>Qty @ Cost</strong><input name='quantity" + displaycount + "' type='text' size='6' maxlength='6' align='top'> @ <input align='top' name='repaircost" + displaycount + "' type='text' id='repaircost" + displaycount + "' size='10' maxlength='10'><BR>";
}

finalcount = displaycount;
data = data + "<input type=hidden name=repaircount id=repaircount value=" + finalcount + ">";

if (document.layers) {
document.layers.repairlist.document.write(data);
document.layers.repairlist.document.close();
}

else {
if(document.getElementById) {
document.getElementById('repairlist').innerHTML = data;
}
else {
return;
}
}
}
else {
window.alert("There's a maximum of 15 entries.")
}
}
</SCRIPT>


</head>

<META content="MSHTML 5.00.2920.0" name=GENERATOR>


<body>

Add Expense

<P><STRONG>Howmany Rent option Do you have?</STRONG></P>
<FORM id=counter name=counter>
<p>
<select multiple name="Branch" id="select3">
<cfoutput query="Branch">
<option value="#Branch#">#Branch#</option>
</cfoutput>
</select>

</p>



&nbsp;&nbsp;
<INPUT onclick=addRepair() type=button value="Set Number">
</FORM>
<FORM action=/expenses_processor.cfm method=post name=addedit
onsubmit="return _CF_checkaddedit(this)">

<STRONG>Rent price</STRONG>&nbsp;
<input
name=repairtype1 type=hidden value=1> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<STRONG>Qty
@ Cost</STRONG> <INPUT align=top maxLength=6 name=quantity1 size=6>
@
<INPUT align=top id=repaircost1 maxLength=10 name=repaircost1
size=10> <BR>


<DIV id=repairlist style="POSITION: relative"

name="repairlist"></DIV>

<INPUT name=Submit type=submit value="Add Repair"> &nbsp;&nbsp;&nbsp;&nbsp;
<INPUT name=reset type=reset value="Clear Form">

</FORM>






</body>

</html>
×

Success!

Help @mohsena spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...