Jump to content
php.lv forumi

select onchange with confirm


anonīms

Recommended Posts

I-netā pēc šiem vārdiem neko neatradu.

Tātad lietoju šādu kodu:

<select name='iespejas' onchange='location = this.options[this.selectedIndex].value;'>
...
<option value="/forums/topic/'.$temats['temata_id'].'/delete/">Dzēst tematu</option>

Vai ir iespējams, ka kādam noteiktam value (vai arī visiem) pirms nostrādā location tiek izmests apstiprināšanas logs ar to, vai tiešām tas ir nepieciešams (Ok/Cancel)?

Paldies.

Edited by anonīms
Link to comment
Share on other sites

<select name='iespejas' onchange='if(confirm("Točna dzēst?")){location = this.options[this.selectedIndex].value;}'>

 

 

Edit: ja gribi atsevišķai grupai prasīt, tad šitā var mēģināt:

 

<select onchange="doStuff(this);">
<option value="/dzest/kkas/">Dzēst</option>
<option value="/cits/kkas/asd/">Darīt</option>
<option value="/ok/es">Neko</option>

</select>
<script type="text/javascript">
function doStuff(e){
	var index = e.selectedIndex;
	var link = e.options[index].value;

	//Ja indekss ir viens vai otrs, pārbaudam
	if(index == 0 || index == 1){
		if(!confirm('Tiešām to darīsi?')){
			return false;
		}
	}

	location.href = link;
}
</script>

Edited by briedis
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...