LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-27-2006, 07:50 AM   #1
Manashi
LQ Newbie
 
Registered: Jan 2006
Posts: 27

Rep: Reputation: 15
Question Unable to create box with button click ...using Javascript


hi ...
i am workin on php usin Postgresql in linux
I hav created a text box and two buttons name MORE and FEWER...

The Function of MORE : Everytime i will click it ... it should create a row havin combo box and text box

The Function of FEWER : Everytime i will click it ... it should delete one row havin combo box and text box from the web page...

i hav used java scripts

the code is as follows :-

Quote:
function addRow(frmCriteria)
{
var tmp = frmCriteria.sub_cnt.value;
tmp++;
frmCriteria.sub_cnt.value = tmp;
frmCriteria.action = "cutoff.php?group="+frmCriteria.grp_id.value;
}

function removeRow(frmCriteria)
{
if( frmCriteria.sub_cnt.value > 1)
{
var tmp = frmCriteria.sub_cnt.value;
tmp--;
frmCriteria.sub_cnt.value = tmp;
frmCriteria.action = "cutoff.php?group="+frmCriteria.grp_id.value;
}
else
{
return false;
}
}
when i am executin it its not gettin executed...

the code in side form tag is :-

Quote:
<form name="criteria_frm" action="cutoff_act.php?group=$group" method="POST">

<input type="hidden" name="grp_id" value="<?php echo $group;?>">

**<input type="hidden" name="sub_cnt" value=?? > // i dnt knw how to show the changed value of created and deleted rows here

<input type="submit" onclick="return addRow(document.criteria_frm)" value="More">

<input type="submit" onclick="return removeRow(document.criteria_frm)" value="Fewer">
is there any problem with the code...
Waitin for the Reply...
 
Old 03-27-2006, 11:38 AM   #2
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
I'm not understanding exactly what you're asking, but those submit buttons should be changed to simply buttons or change your onclicks to onsubmits.
 
Old 03-27-2006, 11:55 AM   #3
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
[Nevermind - didn't read post close enough]

Last edited by pnellesen; 03-27-2006 at 12:00 PM.
 
Old 03-27-2006, 11:45 PM   #4
Manashi
LQ Newbie
 
Registered: Jan 2006
Posts: 27

Original Poster
Rep: Reputation: 15
Question

hi ...
my question is with every time i will click MORE button it should create a text box and combobox...
similary everytime i will click "FEWER" button it should remove the text box and combobox...
for different subject i hav to specify the cut of marks and display the result in another page...the subjects r in combo box and the cut of marks will b specified in text box...
if i want more than one subject marks to be displayed...
for that i need another combo box where subject is there and one more text box to specify marks.....
so for generatin that i hav MORE button....
I hav created a Table and inside that i am having the combo box and the Text box...
when i will click the button the action should take place in the table..
bt the code i hav specified is not workin....
when i am clickin the MORE button its goin to another page where result will be displayed

Last edited by Manashi; 03-28-2006 at 05:02 AM.
 
Old 03-28-2006, 05:04 AM   #5
Manashi
LQ Newbie
 
Registered: Jan 2006
Posts: 27

Original Poster
Rep: Reputation: 15
createElement() is used to do the operation
bt i want to know how i can create a text box and combo box inside the table with every time a button is click...
 
Old 03-29-2006, 12:21 AM   #6
Manashi
LQ Newbie
 
Registered: Jan 2006
Posts: 27

Original Poster
Rep: Reputation: 15
hi..
i hav got the solution for above problem...
but my new doubt is...
when i am clickin thr MORE button new combo box is gettin created but data is not there in it that was in 1st combo box...
the code is as follows :-
Quote:
function insRow()
{
var x=document.getElementById('mytab').insertRow(0)
var y=x.insertCell(0)
var z=x.insertCell(1)
var txt1=document.createElement("input");
var txt2=document.createElement("select");
txt1.size="5";
y.appendChild(txt1);
z.appendChild(txt2);
}
the code inside the form tag is :-
Quote:
<form name="chg" action="9.php" method="POST">
<table cellspacing=2 cellpadding=2 border=1>
<tr><th>col1</th></tr>
<tr><td>
<table>
<tr>
<th>head1</th>
<th>head2</th>
</tr>
</table>
</td></tr>
<tr><td>
<table id="mytab">
<tr><td><input type="text" size=5 name="nam1"></td>
<td><select name="nam2" id="sel">
<option>java</option>
<option>C++</option>
<option>DS</option> </td>
</tr>

</table>
</td></tr>
<tr><td><input type="button" onclick="insRow()" name="but" value="ADD">
</td></tr>
</table>
</form>
here i hav inserted the data in combobox but actually the data is taken from DB and its inserted in combobox by using PHP tag....
if the above code works then it will work for the DB code in PHP tag also...
Waiting 4 the reply.......
 
Old 03-29-2006, 12:32 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Please ignore this post ... testing
 
Old 03-29-2006, 11:48 PM   #8
Manashi
LQ Newbie
 
Registered: Jan 2006
Posts: 27

Original Poster
Rep: Reputation: 15
Question

MORE Button is working 90% fine

I hav 2 doubts :
1. How to delete a row from table when i will Click FEWER button
2. how to create a combo box with data present in it....
i hav to show the options in it by takin it from database...
i know php tag can be used to retrive the data ...

bt my problem is the new combobox which is gettin created by clicking MORE Button is not showing the options...

can any one provide me with a sample code for these two doubts..
Expectin REply...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make thumb button/third button double-click taboom Linux - Hardware 0 03-20-2006 02:39 PM
Click back browser button 1inxs LQ Suggestions & Feedback 4 10-12-2005 07:07 PM
[javascript] confirm button on php page Erhnam Programming 1 02-24-2005 01:05 PM
can javascript automatically populate login fields and click button for me? opioid Programming 1 02-16-2005 03:58 PM
Unwanted border on button click Rachel Carter Programming 1 02-11-2003 12:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration