/    Sign up×
Community /Pin to ProfileBookmark

Problem about sending form data

Hi friends
There is a html file whose name is user.htm . I use it to add new user to my system it has a form that includes text and button.I control the values of the text and if there is no value at the field of the textbox, an alert appears to warn user. And after that if user enters valid values, the pogram should send form data to the related script.But it doesn’t send.If user enters valid values for the first time, there is no problem but he enters invalid values and after that he enters valid values, this problem occurs.Is there anybody to help me about this?

My code is:

[code]
<html>
<head>
</head>

<body bgcolor=”F9F9F9″>
<form action=”user.php” method=”get”>
<table>
<tr>
<td><font color=”#526569″>Kullan&#305;c&#305; Ad&#305;:</font></td>
<td><input type=”text” name=”k_adi” value=””></td>
</tr>
<tr>
<td><font color=”#526569″>&#350;ifre:</font></td>
<td><input type=”password” name=”sifre” value=””></td>
</tr>
<tr>
<td><font color=”#526569″>&#350;ifre(Yeniden):</font></td>
<td><input type=”password” name=”sifre_y” value=””></td>
</tr>
<tr>
<td><font color=”#526569″>Kullan&#305;c&#305; Tipi:</font></td>
<td>
<select name=”k_tip”>
<option value=”2″ selected>Seçin</option>
<option value=”1″>Admin</option>
<option value=”0″>User</option>
</select>
</td>
</tr>
<tr>
<td align=”right” colspan=”2″><input type=”button” value=”Ekle” onClick=”javascript:
if((k_adi.value!=”)&&(sifre.value!=”)&&(sifre_y.value!=”)&&(k_tip.value!=2))
{
if(sifre.value==sifre_y.value)
{
submit();
window.close();
}
else
{
window.alert(‘Girmi&#351; oldu&#287;unuz &#351;ifreler aras&#305;nda tutars&#305;zl&#305;k var.’);
window.location.href=’user.htm’;
}
}
else
{
window.alert(‘Lütfen tüm alanlar&#305; doldurunuz.’);
window.location.href=’user.htm’;
}
“></td>
</tr>
</table>
</form>
</body>
</html>
[/code]

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@ray326Aug 05.2006 — Use an onsubmit handler to do field validation instead of imbedding it in the widget.
Copy linkTweet thisAlerts:
@black_hawkauthorAug 05.2006 — Thanks for your attention ray326

I modified my code by using onSumbit but same problem occured.The code:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;

&lt;body bgcolor="F9F9F9"&gt;
&lt;script type="text/javascript"&gt;
function controlContent()
{
var k_adi=document.info.k_adi.value;
var sifre=document.info.sifre.value;
var sifre_y=document.info.sifre_y.value;
var k_tip=document.info.k_tip.value;
var control;
if((k_adi!='')&amp;&amp;(sifre!='')&amp;&amp;(sifre_y!='')&amp;&amp;(k_tip!=2))
{
if(sifre==sifre_y)
{
control=true;
window.close();
}
else
{
control=false;
window.alert('Girmi&amp;#351; oldu&amp;#287;unuz &amp;#351;ifreler aras&amp;#305;nda tutars&amp;#305;zl&amp;#305;k var.');
//window.location.href='user.htm';
}
}
else
{
control=false;
window.alert('Lütfen tüm alanlar&amp;#305; doldurunuz.');
//window.location.href='user.htm';
}
return control;
}
&lt;/script&gt;
&lt;form name="info" action="user.php" method="post" onSubmit="return controlContent()"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;font color="#526569"&gt;Kullan&amp;#305;c&amp;#305; Ad&amp;#305;:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="k_adi" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;font color="#526569"&gt;&amp;#350;ifre:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="password" name="sifre" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;font color="#526569"&gt;&amp;#350;ifre(Yeniden):&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="password" name="sifre_y" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;font color="#526569"&gt;Kullan&amp;#305;c&amp;#305; Tipi:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;select name="k_tip"&gt;
&lt;option value="2" selected&gt;Seçin&lt;/option&gt;
&lt;option value="1"&gt;Admin&lt;/option&gt;
&lt;option value="0"&gt;User&lt;/option&gt;
&lt;/select&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right" colspan="2"&gt;&lt;input type="Submit" value="Ekle"&gt;&lt;td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;


May my problem be about cleanup text usage? I heard this function before but i haven't used it.
Copy linkTweet thisAlerts:
@ray326Aug 05.2006 — Declare control=false and remove that window.close().
Copy linkTweet thisAlerts:
@black_hawkauthorAug 05.2006 — Thanks ray326

This is the solution.But the point ,that I did not understend, is 'window.close()'. Why does this method prevent my data to go to the script?
Copy linkTweet thisAlerts:
@ray326Aug 06.2006 — Unknown. Maybe the Javascript engine threw an unhandled exception at that point.
×

Success!

Help @black_hawk 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...