How can I let or not a send with Get method
Posted: Thu Aug 17, 2006 11:59 am
feyd | Please use
the problem here is that the data is sent in all cases. the thing I want is to not send data in the first case (if data=='')
thanks
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have an input text and a hyperlink, so before sending (with the Get method using the hyperlink) I want to check the text given en the input text, if Ok I send data, else I show an error message and I don't send the data,
example:
[syntax="html"]
<script language="javascript">
function AddDataToLink(){
if(document.getElementById('data').value == ''){
alert('No data to send');
}
else{
document.getElementById('link').href = "index.php?data=' "+document.getElementById('data').value+" ' ";
}
}
</script>
<form ...>
<input type=text id='data' name=data>
</form>
<a href='index.php' id='link' onClick='AddDataToLink();'>send</a>
thanks
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]