/    Sign up×
Community /Pin to ProfileBookmark

newbie to JS, help wanted

i have a small problem. Im using PHP for some page and i have a problem
with JavaScripts, cause im not good in JS. So the problem is that with
PHP i get data from MySql and put them into dropdown box, now i want
JS to first check if something is selected in dropdown box (by checking
selected value in dropdown box), if selected value is “” then error else
if value is number 1,2,3…and so on, then if value is larger then “” it
should display dialog box, warning: do u want to delete this record? OK, CANCEL,
if cancel do nothing, but if OK then redirect to some page using this URL
somepage.php?ID=2, now how to change that ID number into the selected one
from dropdown box? IF in dropdown box selected value is 3 how to get that
number into that url: .php?ID=3?

Does anybody have a script for all this, example or whatever
that works would be fine

thx

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryApr 12.2003 — Try this (untested):
[CODE]
<select name="sel" onchange="confirmdelete()">

<script type="text/javascript">
function confirmdelete(){
if (document.getElementById('sel').value <> ''){
if (confirm("Do you want to delete this record?") == 1){
location.replace('delete.php?ID=' + document.getElementById('sel').value);
}
}
}
</script>
[/CODE]


Hope this helps

Adam
Copy linkTweet thisAlerts:
@CrustyDODauthorApr 12.2003 — Hi

first thx for this script and now some more help please

i get syntax error at this line, char 55:

if (document.getElementById('brisi_skupino').value <> '') {

how to fix this?
Copy linkTweet thisAlerts:
@khalidali63Apr 12.2003 — Change this line

if (document.getElementById('sel').value <> ''){

to this

if (document.getElementById('sel').value != ''){

Cheers

Khalid
Copy linkTweet thisAlerts:
@AdamGundryApr 12.2003 — Sorry, I should have spotted that. :rolleyes:

Thanks.

Adam
Copy linkTweet thisAlerts:
@khalidali63Apr 12.2003 — ?

Naah...its all right,

Most of use work in multiple programming languages and this kind of common ommision is understandable,depending upon which language is being used more in any given time

Cheers

Khalid
×

Success!

Help @CrustyDOD 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.25,
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,
)...